title: ElasticSearch JEST Client Java
body: <p>I have written an elasticsearch client in java using JEST API. However, I cannot understand how to get the results from the HIT Object. I keep getting null as the result even though I can see the count of the results is correct.</p>
  
  <p>Here is the relevant code, please let me know how I can correct it. Also note that the record in elasticsearch is simply key-value fields. I would ideally like all the key values in the query result.</p>
  
  <pre><code>    HttpClientConfig clientConfig = new HttpClientConfig.Builder("http://138.15.170.105:9200")
              .multiThreaded(true).build();
      JestClientFactory factory = new JestClientFactory();
      factory.setHttpClientConfig(clientConfig);
      JestClient client = factory.getObject();
  
      String query = "{\n" +
              "    \"query\": {\n" +
              "        \"match\": {\n" +
              "            \"table\":\"pcap/abc\"\n" +
              "        }\n" +
              "    }\n" +
              "}";
      Search.Builder searchBuilder = new Search.Builder(query).addIndex("sampleIndex").addType("sampleType");
      try {
          SearchResult result = client.execute(searchBuilder.build());
          System.out.println(result.getTotal());
  
          List&lt;SearchResult.Hit&lt;String, Void&gt;&gt; hits = result.getHits(String.class);
          //THE FOLLOWING GIVES NULL RESULTS
          for(SearchResult.Hit&lt;String,Void&gt; hit: hits)
              System.out.println(hit.source);
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Essentially based on my understanding, I believe the problem is parsing the SearchResult.Hit</p>