[英]How to highlight frequency of keywords in ElasticSearch?
假设我要搜索三个短语“ Microsoft”,“ Facebook”,“ Google”。
如何使ES返回返回结果中每个术语的频率?
谢谢!
您可能正在寻找术语汇总:
本质上,它将按发现的条件对结果进行分类
我认为explain
API可能会对您有所帮助。 例如,如果运行以下查询:
GET /your_index/your_type/_search
{
"explain": true,
"query" : {
"match": {
"company" : "Google"
}
}
}
结果可能是:
{
"took": 9,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 11.7377,
"hits": [
{
"_shard": 1,
"_node": "n0eQxWrIIPYPlmcXA",
"_index": "your_index",
"_type": "your_type",
"_id": "76991",
"_score": 11.7377,
"_source": {
"company": "Google",
"price": "2008"
},
"_explanation": {
"value": 11.7377,
"description": "weight(id:76991 in 6552) [PerFieldSimilarity], result of:",
"details": [
{
"value": 11.7377,
"description": "fieldWeight in 6552, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0"
}
]
},
{
"value": 11.7377,
"description": "idf(docFreq=2, maxDocs=138180)"
},
{
"value": 1,
"description": "fieldNorm(doc=6552)"
}
]
}
]
}
}
]
}
}
在_explanation
部分下,您可能会看到文档频率:
tf-该术语在特定的打分文档中重复多少次
idf-该术语在所有文档中重复多少次(我想您正在寻找什么)
希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.