Range filter on dates in elasticssearch


(Juan Díaz González) #1

Hi,

I have this mapping:

"new_gompute_history_2015-09-08_10:09:27": {
      "mappings": {
         "linux_user_history": {
            "properties": {
               "oid": {
                  "type": "string",
                  "index": "not_analyzed"
               },
               "updated_at": {
                  "type": "date",
                  "format": "dateOptionalTime"
               },
 ....

But now when I want to do a filter query with the range filter it does not work correctly for example:

GET new_gompute_history_2015-09-08_10:09:27/linux_user_history/_search
{
  "query": {
    "filtered": {
      "filter": {
        "range": {
          "updated_at": {
            "gte": "now-1h"
          }
        }
      }
    }
  }
}

And now It´s :

16:23 Tuesday, 8th of September 2015 (CEST)

and from elasticsearch I get:

{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "new_gompute_history_2015-09-08_10:09:27",
            "_type": "linux_user_history",
            "_id": "oid:user:jdiazg",
            "_score": 1,
            "_source": {
               "oid": "oid:user:jdiazg",
               updated_at": "2015-09-08T14:43:44.920229,
               "versions": [
                  {
                     "dn": {

updated_at": "2015-09-08T14:43:44.920229 < now-1h = 2015-09-08T15:23:00.00000

Please could somebody tell me what is wrong?

Thanks in advance


(system) #2