Elasticsearch,无法使用日期范围查询获得正确结果

0x6upsns  于 2023-01-20  发布在  ElasticSearch
关注(0)|答案(1)|浏览(223)

ElasticSearch索引Map格式,

"mappings": {
        "dynamic": "true",
        "_source": {"enabled": "true"},
        "properties": {
            "topic": {"type": "text"},
            "value": {"type": "text"},
            "date": {"type": "date", "format": "YYYY-MM-DD"}
            }
        }

搜索查询是,

curl -X GET "localhost:9200/sample_index/_search?pretty" -H 'Content-Type: application/json' -d' {"query": {"bool": {"filter": [{"range": {"date": {"gte": "2023-01-14", "lte": "2023-01-16"}}}]}}}'

我本应根据过滤器获得结果,但我获得了为索引sample_index保存的所有文档,而不是根据日期过滤器获得结果
也尝试了"必须“

curl -X GET "localhost:9200/sample_index/_search?pretty" -H 'Content-Type: application/json' -d' {"query": {"bool": {"must": [{"range": {"date": {"gte": "2023-01-14", "lte": "2023-01-16"}}}]}}}'

不走运)将感谢你的帮助

63lcw9qa

63lcw9qa1#

将日期格式“年-月-日”替换为“年-月-日”

相关问题