Elasticsearch java-api Compound queries

hi, I have a code like below

public List<String>compoundSearch()
		compoundsearch = new ArrayList<>();
		QueryBuilder queryBuilder = boolQuery()
	            .must(QueryBuilders.termQuery("device", "Device5"))
	            .must(QueryBuilders.termQuery("gateway", "GTW1"));
		SearchRequestBuilder searchRequestBuilder = client.prepareSearch("logstash-*");

		SearchResponse response = searchRequestBuilder.execute().actionGet();
		for (SearchHit hit : response.getHits()){

		return compoundsearch;


when i execute it , the response returned a null value . what is the problem ?

I guess it's not your actual code, right?

Can you tell on which line you are getting a NPE?
May be the stacktrace?

And please use </> to format your code. I updated your question here.