gpt4 book ai didi

elasticsearch - elasticsearch范围上的多重匹配

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

我有以下数据(示例):

[
{
"name": "eli",
"requests": [
{
"creation": "2016-09-07T00:00:00Z",
"title": "something",
"message": "lorem ipsum",
"priority": 1
},
{
"creation": "2016-09-07T00:00:00Z",
"title": "something",
"message": "lorem ipsum",
"priority": 2
},
{
"creation": "2016-09-07T00:00:00Z",
"title": "something",
"message": "lorem ipsum",
"priority": 5
}
]
},
{
"name": "John",
"requests": [
{
"creation": "2016-09-07T00:00:00Z",
"title": "something",
"message": "lorem ipsum",
"priority": 1
},
{
"creation": "2016-09-07T00:00:00Z",
"title": "something",
"message": "lorem ipsum",
"priority": 2
},
{
"creation": "2016-09-07T00:00:00Z",
"title": "something",
"message": "lorem ipsum",
"priority": 1
}
]
}
]

而且我似乎无法弄清楚要用于请求的映射类型,因此我只能筛选优先级为gte 1和lte 2的用户
这意味着用户eli将不会显示
  • 我尝试将其创建为简单字段并进行如下查询
    {"query": {"bool": {"must": [{"range": {"requests.priority": {"gte": 1, "lte": 2}}}]}}}但它仍然返回用户eli。
  • ,因此我尝试将其设置为嵌套,但仍然无法执行(使用以下查询){"query": {"bool": {"must": [{"nested": {"path": "requests","query": {"range": {"requests.priority": {"gte": 1,"lte": 1}}}}}]}}}任何帮助表示赞赏

  • ps我不确定多重比对是在我的问题中使用的正确术语

    最佳答案

    因此,我的解决方案是更改方法并筛选出那些与我的 flex 支撑条件不符的人,因此示例请求看起来像{"query": {"bool": {"must_not": [{"range": {"requests.priority": {"lt": 1, "gt": 2}}}]}}}

    关于elasticsearch - elasticsearch范围上的多重匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39378186/

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