美文网首页
es 查询 | query 和 filters的区别

es 查询 | query 和 filters的区别

作者: 末日声箫 | 来源:发表于2019-08-05 18:10 被阅读0次

    官网: In the query context, a query clause answers the question “How well does this document match this query clause?” Besides deciding whether or not the document matches, the query clause also calculates a relevance score in the _score meta-field

    可见query和filters的关注点不同

    • query: 此文档和查询语句的匹配 度 如何
    • filters : 此文档和查询语句是否匹配

    query:
    关注匹配度,所以就需要关注相关度评分,也就是说需要去计算相关度评分
    filters:
    而filters只需要关注是否匹配,所以就不需要计算相关度评分,而且经常使用的过滤会被es给缓存,所以他更快。但是因为他没有相关度得分,所以如果不指定字段排序的话,他每一次请求的结果的排序都不一样。
    因此,如果没有相关度得分和对结果排序不考虑的话,用filters会更好

    相关文章

      网友评论

          本文标题:es 查询 | query 和 filters的区别

          本文链接:https://www.haomeiwen.com/subject/ttxvdctx.html