Best way to use Java API to search over last month word of data


(Dar Varley) #1

What's the most efficient way to search over a month of data??

I notice I can't do a scan query with a data aggregation:
AggregationBuilder DATE_AGG = AggregationBuilders.dateHistogram("agg") .field("@timestamp") .interval(DateHistogramInterval.MONTH);

My Query:
QueryBuilder MY_QUERY = QueryBuilders.boolQuery() .must(QueryBuilders.matchQuery("field1", "ABC")) .must(QueryBuilders.matchQuery("field2", "XYZ")) ;

So what I want is the fastest way to filter out documents to a specific month and filter based on field1 AND field2 existing and matching specific Strings. I think I need a match all query with multiple field filters.


(system) #2