Skip to content

Instantly share code, notes, and snippets.

@arielamato
Created July 6, 2011 17:40
Show Gist options
  • 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