title: ElasticSearch Indexing and Searching Not Working Correctly
body: <p>When I Indexed data and then Searched data in one Thread(Process) It works . If I Indexed and stop the process then run only searching to find indexed data, no hits. What is the reason of this propblem or what is my mistake client or something ? I am new at Elastic Search, so I cant find the reason Please Help me.</p>
  
  <pre><code>    org.elasticsearch.node.Node node = nodeBuilder().clusterName("farukest").node();
      Client client = node.client();
  
          String[] deneme = {keyword[0]}; // keyword fetched from database
          for (int i = 0; i &lt; degerler.length; i++) {
  
              IndexResponse response = client.prepareIndex("Ali9".toLowerCase(),"Api",Integer.toString(i))
                      .setSource(jsonBuilder()
                              .startObject()
                              .field("Post Id", degerler[i][0].toString())
                              .field("Post Like Count", degerler[i][1].toString())
                              .field("Post Shares Count", degerler[i][2].toString())
                              .field("Post Comment Count", degerler[i][3].toString())
                              .field("Page Name",degerler[i][4].toString())
                              .field("Message", degerler[i][5].toString())
                              .endObject()
                      ).setRefresh(true)
                      .execute()
                      .actionGet();
  
         SearchResponse r = client.prepareSearch("Ali9".toLowerCase()) // Searching
                      .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
                      .setQuery(termQuery("Message", "Fenerbahçelim".toLowerCase()))
                      .setFrom(0).setSize(60).setExplain(true)
                      .execute()
                      .actionGet();
                          System.out.println(r);
              SearchHit[] hits = r.getHits().getHits();
              System.out.println(hits.length);
              for (SearchHit searchHit : hits) {
              Map&lt;String, Object&gt; source = searchHit.getSource();
                  for (Map.Entry&lt;String,Object&gt; values : source.entrySet()) {
                      System.out.println(values.getValue()+"  ...");
                  }
              }  
  </code></pre>
  
  <p>If I run seperately, Result is 0 Data. If I run these in one process it works.</p>