I have the following Elasticsearch get query:
GET /...
{
"size":"0",
"aggs" : {
"locations" : {
"terms" : { "field" : "locationid.keyword" }
}
}
}
which works on console as it should. But the goal is to have this query programmatic via the Java API. I'm using Spring Boor with ElasticSearchRepository:
@Query("{\"size\" : \"0\" , \"aggs\" : {\"locations\" : {\"terms\" : { \"field\" : \"locationid.keyword\" }}}}")
List<Bucket> findDistinctLocationids();
So, now my problem is the following Exception:
ParsingException[size] query malformed, no start_object after query name
The error message is clear but which annotation or is useful for this case instead of @Query? Or is there any other way to retrive distinct records?