Hi All,
I have created a string field and inserting the date value in [yyyy-mm-dd] format. As per my requirement i can't change the field type to date.When i try to search data using the range query it is not giving the results between two dates.
PUT testdate
{
"mappings": {
"documents": {
"dynamic" : "strict",
"properties": {
"name":{
"type": "string"
},
"cdate":{
"type": "string"
}
}
}
}
}
POST testdate/documents/_bulk
{ "index": { "_id": 1 }}
{ "name" : 10, "cdate" : "2001-01-01" }
{ "index": { "_id": 2 }}
{ "name" : 20, "cdate" : "2001-01-11" }
{ "index": { "_id": 3 }}
{ "name" : 30, "cdate" : "2001-01-25" }
Query
{
"query": {
"bool": {
"must": [
{
"range": {
"cdate": {
"from": "2001-01-01",
"to": "2002-02-02"
}
}
}
],
"must_not": [],
"should": []
}
},
"from": 0,
"size": 10,
"sort": [],
"facets": {}
}
when i tried it is giving wrong data.
please help me.