I am not getting how to use SearchResponse in Aggregation

Here one client method creating problem for me. I went through java api of elastic search but still not getting that client() usage and node usage.
Please help me out.

Here is the syntax.
SearchResponse sr = node.client().prepareSearch()
.addAggregation(
AggregationBuilders.terms("by_country").field("country")
.subAggregation(AggregationBuilders.dateHistogram("by_year")
.field("dateOfBirth")
.dateHistogramInterval(DateHistogramInterval.YEAR)
.subAggregation(AggregationBuilders.avg("avg_children").field("children"))
)
)
.execute().actionGet();

I'd use the REST client: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html

1 Like

Thank you, I also want to import some JSON file through rest client using bulk API. Unfortunately, I'm unable to do, could you please show me the syntax or something related to it that I can do it.

This?

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-bulk.html

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