简体   繁体   English

术语与术语查询的评分不同

[英]scoring of Term vs. Terms query different

I am retrieving documents by filtering and using a term query to apply a score.我正在通过过滤和使用term查询来应用分数来检索文档。 The query should match all animals having a specified color - the more colors are matched, the higher the score of a doc.查询应该匹配具有指定颜色的所有动物 - 匹配的颜色越多,文档的分数越高。 Strange thing is, term and terms query result in a different scoring.奇怪的是, termterms查询会导致不同的评分。

{
    "query": {
        "bool": {
            "should": [
                {"terms": {"color": ["brown","darkbrown"] } },
            ]
        }
    }
}

should be the same like using应该和使用一样

{"term": {"color": {"value": "brown"} } },
{"term": {"color": {"value": "darkbrown"} } }

Query no.查询编号1 gives me the exact same score for a document whether 1 or 2 terms are matched.无论是匹配 1 项还是 2 项,1 都会为文档提供完全相同的分数。 The latter of course returns a higher score, if more colors are matched.如果匹配更多颜色,后者当然会返回更高的分数。

As stated by the coordination factor the returned score should be higher if more terms are matched.协调因子所述,如果匹配更多项,则返回的分数应该更高。 Therefore these two queries should result in the same score - or is because term queries do not analyze the search term?因此这两个查询应该产生相同的分数 - 还是因为term查询不分析搜索术语?

My field is indexed as text.我的字段被索引为文本。 Strings are indexed as an "array" of strings, eg "brown","darkbrown"字符串被索引为字符串的“数组”,例如"brown","darkbrown"

Difference between term vs terms query:术语与术语查询之间的区别:

  • Terms query return documents that contain one or more exact terms in a provided field.术语查询返回在提供的字段中包含一个或多个确切术语的文档。
  • The terms query is the same as the term query, except you can search for multiple values.术语查询与术语查询相同,但您可以搜索多个值。
  • Warning: Avoid using the term query for text fields.警告:避免对文本字段使用术语查询。

As far your this part is concerned就你的这部分而言

or is because term queries do not analyze the search term?还是因为词条查询不分析搜索词条?

Yes, It is because the search term do not analyze the term searched.是的,这是因为搜索词不会分析搜索的词。 It just matches the exact search term.它只匹配确切的搜索词。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM