static Map<String, List<TermsFieldEntry>> convertTermsQueryResponseToTermsMap(QueryResponse response) {
if (response == null || response.getTermsResponse() == null || response.getTermsResponse().getTermMap() == null) {
return Collections.emptyMap();
}
TermsResponse termsResponse = response.getTermsResponse();
Map<String, List<TermsFieldEntry>> result = new LinkedHashMap<String, List<TermsFieldEntry>>(termsResponse
.getTermMap().size());
for (Map.Entry<String, List<Term>> entry : termsResponse.getTermMap().entrySet()) {
List<TermsFieldEntry> terms = new ArrayList<TermsFieldEntry>(entry.getValue().size());
for (Term term : entry.getValue()) {
SimpleTermsFieldEntry termsEntry = new SimpleTermsFieldEntry(term.getTerm(), term.getFrequency());
termsEntry.setField(entry.getKey());
terms.add(termsEntry);