Skip to content

Instantly share code, notes, and snippets.

@arielamato
Created July 6, 2011 17:40
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 arielamato/1067840 to your computer and use it in GitHub Desktop.
Save arielamato/1067840 to your computer and use it in GitHub Desktop.
Sample query
private void addAgeSearchTerm(final BoolQueryBuilder queryBuilder, final Integer minAge, final Integer maxAge) {
for (int i = 0; i <= 4; i++) {
queryBuilder.should(new RangeQueryBuilder("age").from(minAge).to(maxAge + i)
.boost((ageWeight / (i + 1))));
}
for (int i = 0; i <= 3; i++) {
queryBuilder.should(new RangeQueryBuilder("age").from(minAge - i).to(maxAge)
.boost((ageWeight / (i + 1))));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment