Date Aggregation


(Sanjay Reddy) #1

Hi,

I have an index "sanjay" in which i'm sorting based on "OrderDate" (Sorting based on date) using java API. For Date wise sorting this is great.
I'm using the following code to achieve the same.

MultiMatchQueryBuilder query = QueryBuilders.multiMatchQuery(field_name, Search_String);
SearchRequestBuilder req = client.prepareSearch("sanjay")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH).setSize(totalhits);

req.setQuery(query);

SearchResponse res = req.setFetchSource(new String[] { "field_name1", "field_name2" }, null).addSort("orderDate", SortOrder.ASC).execute().actionGet();

But, I want to sort based on Month in OrderDate and also I want to get only the first value in the Sorted Month.
Is there any possiblity of achieving this???
Please help

Thanks & Regards,
Sanjay Reddy


(system) #2