gpt4 book ai didi

date - Elasticsearch在范围查询中找不到值

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

我启动以下查询:

GET archive-bp/_search
{
"query": {
"bool" : {
"filter" : [ {
"bool" : {
"should" : [ {
"terms" : {
"naDataOwnerCode" : [ "ACME-FinServ", "ACME-FinServ CA", "ACME-FinServ NY", "ACME-FinServ TX", "ACME-Shipping APA", "ACME-Shipping Eur", "ACME-Shipping LATAM", "ACME-Shipping ME", "ACME-TelCo-CN", "ACME-TelCo-ESAT", "ACME-TelCo-NL", "ACME-TelCo-PL", "ACME-TelCo-RO", "ACME-TelCo-SA", "ACME-TelCo-Treasury", "Default" ]
}
},
{
"bool" : {
"must_not" : {
"exists" : {
"field" : "naDataOwnerCode"
}
}
}
} ]
}
}, {
"range" : {
"bankCommunicationStatusDate" : {
"from" : "2006-02-27T06:45:47.000Z",
"to" : null,
"time_zone" : "+02:00",
"include_lower" : true,
"include_upper" : true
}
}
} ]
}
}
}

我没有收到任何结果,但是索引中存在该字段。
当我剥离数据所有者部分时,我仍然没有结果。当我剥离bankCommunicationDate时,我得到10个结果,所以有问题。
仅查询bankCommunicationDate:
GET archive-bp/_search 
{
"query" :
{
"range" : {
"bankCommunicationStatusDate" : {
"from" : "2016-04-27T09:45:43.000Z",
"to" : "2026-04-27T09:45:43.000Z",
"time_zone" : "+02:00",
"include_lower" : true,
"include_upper" : true
}
}
}
}

我的索引的映射包含以下bankCommunicationStatusDate字段:
"bankCommunicationStatusDate": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
}

而且Elasticsearch中有字段 bankCommunicationStatusDate 的值:
  • “bankCommunicationStatusDate”:“2016-04-27T09:45:43.000Z”
  • “bankCommunicationStatusDate”:“2016-04-27T09:45:47.000Z”

  • 怎么了?

    最佳答案

    您使用什么版本的Elastic Search?
    我想原因是您应该使用“gte / lte”而不是“from / to / include_lower / include_upper”。

    根据版本0.90.4的文档
    https://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-range-query.html

    Deprecated in 0.90.4.
    The from, to, include_lower and include_upper parameters have been deprecated in favour of gt,gte,lt,lte.

    奇怪的是,我在 flex 搜索1.7版上尝试了您的示例,它返回数据!
    我猜实际贬值发生的时间要晚得多-在1.7到更高版本之间。

    顺便说一句。您可以使用适用于Chrome的Sense插件和以下代码进一步隔离问题:
    DELETE /test
    PUT /test
    {
    "mappings": {
    "myData" : {
    "properties": {
    "bankCommunicationStatusDate": {
    "type": "date"
    }
    }
    }
    }
    }

    PUT test/myData/1
    {
    "bankCommunicationStatusDate":"2016-04-27T09:45:43.000Z"
    }
    PUT test/myData/2
    {
    "bankCommunicationStatusDate":"2016-04-27T09:45:47.000Z"
    }


    GET test/_search
    {
    "query" :
    {
    "range" : {
    "bankCommunicationStatusDate" : {
    "gte" : "2016-04-27T09:45:43.000Z",
    "lte" : "2026-04-27T09:45:43.000Z"
    }
    }
    }
    }

    关于date - Elasticsearch在范围查询中找不到值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36889962/

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