gpt4 book ai didi

elasticsearch - “plain”术语查询与使用过滤器的术语查询之间的区别

转载 作者:行者123 更新时间:2023-12-02 23:03:14 25 4
gpt4 key购买 nike

我试图了解两者之间的区别:

  • 一个“普通” elasticsearch查询,它将与术语查询匹配,并返回一定数量的匹配。
  • 和一个过滤的查询(因此使用过滤器)将返回相同的匹配数。

  • 这是 术语查询:
    GET _search
    {
    "query": {
    "terms": {
    "childcareTypes": [
    "SOLE_CHARGE",
    "OUT_OF_SCHOOL",
    "BABY_SITTING"
    ],
    "minimum_match": 3
    }
    }
    }

    这是 过滤的版本:
    GET _search
    {
    "query": {
    "filtered": {
    "filter": {
    "terms": {
    "childcareTypes": [
    "SOLE_CHARGE",
    "OUT_OF_SCHOOL",
    "BABY_SITTING"
    ],
    "execution": "and"
    }
    }
    }
    }
    }

    两者都返回8000总命中率(相对于我的指数)。

    这是“普通”字词查询的结果:
    {
    "took": 7,
    "timed_out": false,
    "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
    },
    "hits": {
    "total": 8000,
    "max_score": 5.134171,
    "hits": [
    {
    "_index": "bignibou",
    "_type": "advertisement",
    "_id": "AUs2T2lt3L5LNr7nkot2",
    "_score": 5.134171,
    "_source": {
    "childcareWorkerType": "AUXILIAIRE_PARENTALE",
    "childcareTypes": [
    "SOLE_CHARGE",
    "OUT_OF_SCHOOL",
    "BABY_SITTING"
    ],
    "address": {
    "latitude": 48.8532558,
    "longitude": 2.36584
    },
    "giveBath": "EMPTY"
    }
    },
    ...

    这是“已过滤”查询的结果:
    {
    "took": 3,
    "timed_out": false,
    "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
    },
    "hits": {
    "total": 8000,
    "max_score": 1,
    "hits": [
    {
    "_index": "bignibou",
    "_type": "advertisement",
    "_id": "AUs2T2lt3L5LNr7nkot2",
    "_score": 1,
    "_source": {
    "childcareWorkerType": "AUXILIAIRE_PARENTALE",
    "childcareTypes": [
    "SOLE_CHARGE",
    "OUT_OF_SCHOOL",
    "BABY_SITTING"
    ],
    "address": {
    "latitude": 48.8532558,
    "longitude": 2.36584
    },
    "giveBath": "EMPTY"
    }
    },
    ....

    那么两者之间有什么区别?

    最佳答案

    这与查询过滤器(more information here)之间的差异有关。

    在您的情况下,与terms查询不同,terms过滤器:

  • 缓存的
  • 不计算分数:所有匹配的文档的_score为1(查看结果)

  • 因此,最大的区别是 filtered查询将比“普通” terms查询更快。

    关于elasticsearch - “plain”术语查询与使用过滤器的术语查询之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28235025/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com