Top hits not is parsing with java api client

I stumbled onto this discussion while I was writing aggregation with limiting response to limited number of fields.

SearchRequest searchRequest = new SearchRequest.Builder()
    .source(SourceConfig.of(s -> s.filter(f -> f.includes(List.of(// 10 fields // )))))

My query :

"aggregations": {
    "someField": {
      "aggregations": {
        "documents": {
          "top_hits": {
            "size": 20,
            "_source": {
              "includes": [
      "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


What is the dependency tree?

mvn dependency:tree

Hi David,

I did a bit of reading and looks like the problem is with my index documents have both long and string mappings i.e. if I search with all String fields then no issues but on mixing them causes problem (mini problem).

and I was using jackson 2.10.x (big problem), upgrading to jackson 2.17.0 resolved it.

other configs java 8, es 8.12.x


This is well documented here: