Hi i write a aggregation query in new java api using HighLevelClient. I need help to add must and must not range query for filtering the data.
- How can i add it ?
- Is it possible to add json query with query builder ?
My code is as like below
Map<String, String> aggVal = = new Map<String, String>();
String index = aggVal.get("Index");
String mainAggField = aggVal.get("Main_Aggregation_FieldName");
String subAggField = aggVal.get("Sub_Aggregation_FieldName");
String histFormat = aggVal.get("Histogram_Format");
String histIntrvl = aggVal.get("Histogram_Interval");
long minDocCount = Long.valueOf(aggVal.get("Min_Doc_Count"));
DateHistogramInterval Intrval = new DateHistogramInterval(histIntrvl);
SearchResponse response = client.search(new SearchRequest(index)
.source(new SearchSourceBuilder()
.aggregation(
AggregationBuilders.dateHistogram("mainAgg")
.field(mainAggField)
.dateHistogramInterval(Intrval)
.format(histFormat)
.minDocCount(minDocCount)
.subAggregation(
AggregationBuilders.terms("subAgg").field(subAggField)
.minDocCount(minDocCount) ))
.size(0) ));