Elasticsearch index mapping format,
"mappings": {
"dynamic": "true",
"_source": {"enabled": "true"},
"properties": {
"topic": {"type": "text"},
"value": {"type": "text"},
"date": {"type": "date", "format": "YYYY-MM-DD"}
}
}
search query is,
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"}}}]}}}'
I should have got the result based on filter, but i am getting all the documents saved for index sample_index , not getting result based on date filter
tried with must as well,
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 :( Will appreciate your help
CodePudding user response:
replace date format "YYYY-MM-DD" to "yyyy-MM-dd"