Range query elasticsearch


(Aniket) #1

I have written following query to get data from elasticsearch.

SearchRequest requestQuery =
      Requests.searchRequest(ConstantsValue.indexName)
       .types(ConstantsValue._Type)
       .source("{size:999999,"
         + "\"_source\" : "
          + "[\"DTCREATED\", \"STATUS\"]"
          + ",\"aggs\": "
          + "{\"group_by_STATUS\": {\"terms\": {\"field\": \"STATUS\"},"
          + "\"aggs\" : "
          + "{\"group_by_DATE\" : {\"date_histogram\" : "
          + "{\"field\" : \"DTCREATED\", \"interval\" : \"day\","
          + "\"format\" : \"yyyy-MM-dd\" },"
          + "\"aggs\" : "
          + "{\"grades_count\" : { \"value_count\" : { \"field\" : \"STATUS\" } }}}}}}}");

This query gives me day wise count of status. But now I want to add date range lets say from 2016-09-01T18:30:00.000Z to 2016-10-01T18:30:00.000Z. I want daily status count for that date range. I have tried my best but not found any answer. Any help is greatly appreciated


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.