Question

I want to to query in the dats while using the querystring.

From what I can read here this should work.

{
    "query": {
        "query_string": {
            "query": "date:[20100101 TO 20141231]"

        }
    },
    "size": 10

}

I get no errors but no results either.

I have date fields in the mapping (shortened for your convenience).

{
   "cases": {
      "mappings": {
         "texcaseelastic": {
            "properties": {
               "dateIn": {
                  "type": "date",
                  "format": "dateOptionalTime"
               },
               "type": {
                  "type": "string"
               }
            }
         }
      }
   }
}

And I have at least a few that should fall in that range.

"dateIn": "2011-11-21T00:00:00",

Any help would be welcome. Thanks.

Was it helpful?

Solution

There is a typo in your query. You are doing a search by specific field and your field name is incorrect.

Change date to dateIn, like the following:

{
    "query": {
        "query_string": {
            "query": "dateIn:[20100101 TO 20141231]"

        }
    },
    "size": 10

}

OTHER TIPS

{
    "query":{"range": {"date_column_name": {"gte": "2011-11-20T00:00:00", "lte": "2011-11-22T00:00:00"}}},
    "size": 10
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top