gpt4 book ai didi

elasticsearch - 如何在 Elasticsearch Query 中传递特定字段的值列表

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

我有一个查询要搜索 provider_id来自 Elastic Search Cluster .我正在使用以下查询来获取单个 provider_id 的结果但在弄清楚如何传递提供者列表方面需要帮助。

{
"query": {
"bool": {
"must": [{
"match": {
"message.provider_id": {
"query": 943523,
"type": "phrase"
}
}
}]
}
}
}

假设我想搜索 provider_ids = [913523, 923523, 923523, 933523, 953523]那么我应该如何修改查询?

最佳答案

您可以将 provider_id 索引为 not_analyzed,然后使用术语查询:

POST /test_index/_search
{
"query": {
"terms": {
"message.provider_id": [
"913523", "923523", "923523", "933523", "953523"
]
}
}
}

或者如果您不需要分数,则作为带有过滤器的 bool 查询:
POST /test_index/_search
{
"query": {
"bool": {
"filter": [
{
"terms": {
"message.provider_id": [
"913523", "923523", "923523", "933523", "953523"
]
}
}
]
}
}
}

关于elasticsearch - 如何在 Elasticsearch Query 中传递特定字段的值列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39495593/

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