![](/img/trans.png)
[英]Elasticsearch: Influence scoring with custom score field in document
[英]Elasticsearch: Having document score equal number of hits in field
使用elasticsearch,我正在搜索通常具有大量文本的字段上的索引,而我只想知道每个文档匹配查询的次数。 有人知道这样做的好方法吗? 如果可能的话,我想通过分数值来做。 因此,例如,如果我在“快速的棕色狐狸跳过了懒惰的狐狸”上搜索了“狐狸”,则会得到以下内容:
“ _score”:2.0
默认的评分模型也将其记入图片,但这并不是唯一的说明。 您要寻找的是术语频率。 默认评分模型基于TF-IDF(术语频率和文档反向频率)以及字段长度。 您可以在此处了解更多信息。
{
"query": {
"function_score": {
"query": {
"match": {
"field": "fox"
}
},
"boost_mode": "replace",
"functions": [
{
"script_score": {
"script": "_index['field']['fox'].tf()"
}
}
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.