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"}}}]}}}'
不走运)将感谢你的帮助
1条答案
按热度按时间63lcw9qa1#
将日期格式“年-月-日”替换为“年-月-日”