我有这样的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'].
更多推荐
发布评论