I am migrating elasticsearch from old to new elasticsearch java client.
I encounter this problem wherein I issue a request query, then the response has null values.
The code below is how I request:
    SearchRequest request = requestBuilder.build();
    SearchResponse<ObjectNode> response;
    try {
      response = elasticCLient.search(request, ObjectNode.class);
    } catch (final IOException e) {
      throw Exception(e);
    }
As you can see it uses ObjectNode.class
Problem arises when the response has null value.
A null pointer exception happens which I think the response cannot be serialized because of the null value.
The response when viewed in kibana is like this:
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [
      {
        "_index" : "robots_20220613111538",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : null,
        "_source" : {
          "path" : "C:/storage/1",
          "name" : "barbie.jpg",
          "collection" : [ ]
        },
        "sort" : [
          null,
          "barbie.jp",
          1664377265000
        ]
      },
      {
        "_index" : "robots_20220613111538",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : null,
        "_source" : {
          "path" : C:/storage/1",
          "name" : "hellokitty.jpg",
          "collection" : [ ]
        },
        "sort" : [
          null,
          "hellokitty.jpg",
          1664377266000
        ]
      }
    ]
  }
}
How to deal with this kind of response?
Are there other ways instead of using ObjectNode.class ?
Any help is greatly appreciated.

