Getting the Object from searchResponse

I am trying to retrieve the Object from my searchresponse which I obtained through

searchResponse =;

I am using the following method

    SearchHit[] result = searchResponse.getHits().getHits();

    List<SearchHit> result2 = Arrays.asList(result);

    List<CheckoutCartActivity> result3 = new ArrayList<>();

    for (SearchHit searchHit : result2)
        Map<String, Object> resultMap = searchHit.getSourceAsMap();
        System.out.println("resultMap is " + resultMap);

       return  result2;

For which I am getting NullPointerException at


Can you please help me with this.

Is there any alternate and better way to retrieve the Class Object from searchResponse ?

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