Skip to content

Instantly share code, notes, and snippets.

@sanity
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanity/c825c69de3ab9a991640 to your computer and use it in GitHub Desktop.
Save sanity/c825c69de3ab9a991640 to your computer and use it in GitHub Desktop.
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