Elasticsearch java-api Compound queries

hi, I have a code like below

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

		SearchResponse response = searchRequestBuilder.execute().actionGet();
	
		
		System.out.println(response.contextSize());
		
		for (SearchHit hit : response.getHits()){
			compoundsearch.add(hit.getSourceAsString());
		}

		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.