Hi,
I implement below code for fetching data from Elastic Search, but performance is very slow.
Please check below code and please improve the solution
package com.cemciq.test;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.entity.ContentType;
import org.apache.http.nio.entity.NStringEntity;
import org.apache.lucene.search.Query;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.cemciq.Constents;
import com.cemciq.solr.client.CemSolrClient;
import com.cemciq.util.CemException;
public class TestClass {
	public static void main(String[] args) throws CemException, IOException, JSONException {
	
		TestClass.getCIQMatchedCompanyListForSorted1();
		
	}
	
public static void getCIQMatchedCompanyListForSorted1() throws CemException, IOException, JSONException {
		
	
		Map<String, String> paramMap = new HashMap<String, String>();
		List testList=new ArrayList();
		SearchResponse response1;
		//Client client; 
		JSONArray hitsArray;
		Query query;
		RestClient restClient = RestClient.builder(new HttpHost("172.21.153.176", 9200, "http")).build();
		String coalitionId="";
		
		
		String abc="12 WEST CAPITAL MANAGEMENT LP";
		
		//paramMap.put("minimum_should_match", "90");
		//paramMap.put("pretty", "true");
		
		HttpEntity entity = new NStringEntity(
				"{\n" +
		
						"    \"query\" : {\n" +
							
						"	\"bool\" : {\n"+
								"	\"minimum_should_match\" : \"10%\","+
								
								"    \"must\": [ \n"+
										"{ \n"+
										
											"  \"match_phrase\" : { \n"+
											"  \"bank_client_entity_name.keyword\" : { \n"
											+ " \"query\" : \"12 WEST CAPITAL MANAGEMENT LP\" } \n"+
											"} \n"+
								
											"} \n"+
										"] \n"+	
						
						          "} \n"+
						
						       "}, \n"+ 
						" \"size\" : 10 \n"+
						"}", ContentType.APPLICATION_JSON);
		
	
		Response response = restClient.performRequest("GET", "/hist_latest_5.5.0/_search",Collections.<String, String>emptyMap(),
				entity);
		BufferedInputStream br = new BufferedInputStream(response.getEntity().getContent());
		
		String res = "";
		while (br.available()>0) {
	  		res += (char)br.read();
	  	}
		
		 br.close();
		 
		
		 
	    JSONObject json = new JSONObject(res);
		JSONObject hits = json.getJSONObject("hits");
		 hitsArray = hits.getJSONArray("hits");
		ArrayList<Object> coalitionList = new ArrayList<Object>();
		for (int i=0; i<hitsArray.length(); i++) {
			ArrayList<String> fileNameIdArrList = new ArrayList<String>();
		JSONObject h = hitsArray.getJSONObject(i);
		JSONObject sourceJObj = h.getJSONObject("_source");
		
		System.out.println("sourceJObj :"+i+" "+sourceJObj);
		
		
	}
		
		
	
}
	
	
	
	
}