private static void addFilterForTopicId( BoolFilterBuilder filterBuilder, InclusionExclusionId id ) { NestedFilterBuilder filterForId = FilterBuilders.nestedFilter( EsContent.TOPICS + "." + EsTopic.TYPE_NAME, FilterBuilders.termFilter( EsContent.TOPICS + "." + EsTopic.TYPE_NAME + "." + EsContent.ID, id.getId() ) ); if (id.isExcluded()) { filterBuilder.mustNot(filterForId); } else { filterBuilder.must(filterForId); } }
private static FilterBuilder buildAvailabilityFilter() { NestedFilterBuilder rangeFilter = FilterBuilders.nestedFilter( EsContent.LOCATIONS, FilterBuilders.andFilter( FilterBuilders.rangeFilter(EsLocation.AVAILABILITY_TIME) .lte(ElasticsearchUtils.clampDateToFloorMinute(DateTime.now()) .toString()), FilterBuilders.rangeFilter(EsLocation.AVAILABILITY_END_TIME) .gte(ElasticsearchUtils.clampDateToFloorMinute(DateTime.now()) .toString()) ) ); return FilterBuilders.orFilter( rangeFilter, FilterBuilders.hasChildFilter(EsContent.CHILD_ITEM, rangeFilter) ); }
/** * Generate the field name term for the field name for filters */ private NestedFilterBuilder fieldNameTerm( final String fieldName, final FilterBuilder fieldValueBuilder ) { final BoolFilterBuilder booleanQuery = FilterBuilders.boolFilter(); booleanQuery.must( FilterBuilders.termFilter( IndexingUtils.FIELD_NAME_NESTED, fieldName ) ); booleanQuery.must( fieldValueBuilder ); return FilterBuilders.nestedFilter( IndexingUtils.ENTITY_FIELDS, booleanQuery ); }