Elasticsearch索引映射格式,
"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的所有文档,没有得到基于日期过滤器的结果
try withmust,
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"}}}]}}}'
no luck:(谢谢你的帮助
替换日期格式";yyyy-MM-dd"