Skip to content

Instantly share code, notes, and snippets.

@sanity
Last active Aug 29, 2015
Embed
What would you like to do?
BoolFilterBuilder filter = FilterBuilders.boolFilter()
.must(termFilter("campaign_id", 830))
.mustNot(idsFilter("247", "1401", "611", "2884", "1901"));
QueryBuilder qb = QueryBuilders
.moreLikeThisFieldQuery("indicators")
.likeText("247 1401 611 2884 1901")
.minTermFreq(1)
.maxQueryTerms(20);
SearchResponse response = client.prepareSearch("rec_dest")
.addField("id")
.setTypes("destination")
.setSearchType(QUERY_AND_FETCH)
.setQuery(qb)
.setPostFilter(filter)
.setFrom(0)
.execute()
.actionGet();
return response.getHits().getTotalHits();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment