I stumbled onto this discussion while I was writing aggregation with limiting response to limited number of fields.
SearchRequest searchRequest = new SearchRequest.Builder()
.index("idx_name")
.query(query)
.source(SourceConfig.of(s -> s.filter(f -> f.includes(List.of(// 10 fields // )))))
.build();
My query :
"aggregations": {
"someField": {
"aggregations": {
"documents": {
"top_hits": {
"size": 20,
"_source": {
"includes": [
"field1",
"field2",
"field3",
..
"fieldN"
]
}
}
}
},
"terms": {
"field": "someField",
"size": 100
}
}
}
if i add more than 3 fields, the client is not able to parse the response.
i tried my query with java api client setup using this tutorial : Basic authentication | Elasticsearch Java API Client [8.12] | Elastic
i get following error when i client tries to parse the response :
Method threw 'java.lang.NoSuchMethodError' exception. Cannot evaluate co.elastic.clients.elasticsearch.core.SearchResponse.toString()
Any guidance would be appreciated. thanks