Elasticsearch:

编程入门 行业动态 更新时间:2024-10-27 12:26:18
Elasticsearch:_fore始终为0(tf())(Elasticsearch : _score always 0 for tf())

我有这样的groovy脚本:

_index[field][term].tf()

我正在索引这个groovy脚本

POST /_scripts/groovy/getTF { "script": "_index[field][term].tf()" }

然后运行以下查询总是返回_score为零(感知命令)

POST /my_index/document/_search { "query": { "function_score": { "query": { "match": { "text": "algorithms" } }, "functions": [ { "script_score": { "script_id": "getTF", "lang" : "groovy", "params": { "term": "algorithms", "field": "text" } } } ], "boost_mode": "replace" } }, "size": 10, "fields": ["text"] }

我在这里做错了什么?

这是字段的映射

PUT /ap_dataset/document/_mapping { "document": { "properties": { "docno": { "type": "string", "store": true, "index": "not_analyzed" }, "text": { "type": "string", "store": true, "index": "analyzed", "term_vector": "with_positions_offsets_payloads", "analyzer": "my_english" } } } }

I have this kind of groovy script:

_index[field][term].tf()

I am indexing this groovy script

POST /_scripts/groovy/getTF { "script": "_index[field][term].tf()" }

Then running the following query always returns _score to be zero (sense command)

POST /my_index/document/_search { "query": { "function_score": { "query": { "match": { "text": "algorithms" } }, "functions": [ { "script_score": { "script_id": "getTF", "lang" : "groovy", "params": { "term": "algorithms", "field": "text" } } } ], "boost_mode": "replace" } }, "size": 10, "fields": ["text"] }

What am I doing wrong here?

This is the mapping for the fields

PUT /ap_dataset/document/_mapping { "document": { "properties": { "docno": { "type": "string", "store": true, "index": "not_analyzed" }, "text": { "type": "string", "store": true, "index": "analyzed", "term_vector": "with_positions_offsets_payloads", "analyzer": "my_english" } } } }

最满意答案

0项频率的解释是您所查找的术语在索引中找不到。 您的脚本收到称为algorithms (这是复数)的术语。

但english分析器正在改变复数为单数,作为英语词干的结果。 因此,即使您的文本包含algorithms ,索引中的术语也不会被_index['text']['algorithms'] 。

The explanation for the 0 term frequency is that the term you are looking for is not found in the index. Your script receives the term called algorithms (which is plural).

But the english analyzer is changing plurals to singular, as a result of the english stemmer. So, even if your text is containing algorithms, the term in the index is algorithm which will not be found by _index['text']['algorithms'].

更多推荐

本文发布于:2023-07-21 23:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1214872.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Elasticsearch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!