Parsing query string with custom aggregation, using Search API

I've installed a plugin to elastic (GitHub - opendatasoft/elasticsearch-aggregation-geoclustering: An Elasticsearch plugin to aggregate Geo Points in clusters.) and I have an endpoint (high level rest client) that takes an ES query body string and builds it with SearchSourceBuilder.

Using kibana, the plugin works fine:

  "size": 0,
  "query": {
    "match_all": {}
  "aggs": {
    "clusters": {
      "geo_point_clustering": {
        "field": "geo.point",
        "zoom": 5

And I get the expected result.

However, the SearchSourceBuilder have trouble parsing the "geo_point_clustering" aggregation


threw exception [Request processing failed; nested exception is ParsingException[Unknown aggregation type [geo_point_clustering]]; nested: NamedObjectNotFoundException[[31:30] unknown field [geo_point_clustering]];] with root cause

The exception comes from where the request body is converted into a SearchSourceBuilder

val searchSourceBuilder = SearchSourceBuilder().timeout(TimeValue(5, TimeUnit.SECONDS))
val searchModule = SearchModule(Settings.EMPTY, false, emptyList())
val xContentRegistry = NamedXContentRegistry(searchModule.namedXContents)
      DeprecationHandler.THROW_UNSUPPORTED_OPERATION, body)

So my question is (i think) how can I add the custom aggregation type to this parser?



I dont now if I to help but you can perform this way using query in format json:

I should've stated this in the post, but we're on v7.10. I'm also in particular interested in using SearchSourceBuilder. Thanks for the suggestion!

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