// Recency boost. We differentiate between various (random) levels of
// recency
if (recencyBoost) {
Calendar date = Calendar.getInstance();
// Last week
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(MODIFIED);
date.add(Calendar.WEEK_OF_YEAR, -1);
rangeQueryBuilder.gt(date.getTimeInMillis()).boost(10);
booleanQuery.should(rangeQueryBuilder);
// Last month
rangeQueryBuilder = QueryBuilders.rangeQuery(MODIFIED);
date.add(Calendar.WEEK_OF_YEAR, -3);
rangeQueryBuilder.gt(date.getTimeInMillis()).boost(5);
booleanQuery.should(rangeQueryBuilder);
// Last year
rangeQueryBuilder = QueryBuilders.rangeQuery(MODIFIED);
date.add(Calendar.MONTH, -5);
rangeQueryBuilder.gt(date.getTimeInMillis()).boost(2);
booleanQuery.should(rangeQueryBuilder);
}
QueryBuilder unfilteredQuery = queryBuilder;
List<FilterBuilder> filters = new ArrayList<FilterBuilder>();