本文整理汇总了Java中org.elasticsearch.index.query.FilterBuilders.orFilter方法的典型用法代码示例。如果您正苦于以下问题:Java FilterBuilders.orFilter方法的具体用法?Java FilterBuilders.orFilter怎么用?Java FilterBuilders.orFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.index.query.FilterBuilders
的用法示例。
在下文中一共展示了FilterBuilders.orFilter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildAvailabilityFilter
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
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)
);
}
示例2: buildFilter
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
@Override
public FilterBuilder buildFilter(final String key, final String[] rangeValues) {
if (rangeValues == null || rangeValues.length == 0) {
throw new IllegalArgumentException("Filter values cannot be null or empty");
}
if (rangeValues.length == 1) {
return buildSingleRangeFilter(key, rangeValues[0]);
}
FilterBuilder[] builders = new FilterBuilder[rangeValues.length];
for (int i = 0; i < rangeValues.length; i++) {
builders[i] = buildSingleRangeFilter(key, rangeValues[i]);
}
return FilterBuilders.orFilter(builders);
}
示例3: buildTopicIdFilter
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
public static FilterBuilder buildTopicIdFilter(
ImmutableList<ImmutableList<InclusionExclusionId>> topicIdSets
) {
ImmutableList.Builder<FilterBuilder> topicIdFilters = ImmutableList.builder();
for (List<InclusionExclusionId> idSet : topicIdSets) {
BoolFilterBuilder filterForThisSet = FilterBuilders.boolFilter();
for (InclusionExclusionId id : idSet) {
addFilterForTopicId(filterForThisSet, id);
}
topicIdFilters.add(filterForThisSet);
}
OrFilterBuilder orFilter = FilterBuilders.orFilter();
topicIdFilters.build().forEach(orFilter::add);
return orFilter;
}
示例4: buildActionableFilter
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
public static FilterBuilder buildActionableFilter(
Map<String, String> actionableParams,
Optional<Id> maybeRegionId,
ChannelGroupResolver channelGroupResolver
) {
OrFilterBuilder orFilterBuilder = FilterBuilders.orFilter();
if (actionableParams.get("location.available") != null) {
orFilterBuilder.add(buildAvailabilityFilter());
}
DateTime broadcastTimeGreaterThan =
actionableParams.get("broadcast.time.gt") == null ?
null : DateTime.parse(actionableParams.get("broadcast.time.gt"));
DateTime broadcastTimeLessThan =
actionableParams.get("broadcast.time.lt") == null ?
null : DateTime.parse(actionableParams.get("broadcast.time.lt"));
if (broadcastTimeGreaterThan != null || broadcastTimeLessThan != null) {
orFilterBuilder.add(
buildBroadcastRangeFilter(
broadcastTimeGreaterThan,
broadcastTimeLessThan,
maybeRegionId,
channelGroupResolver
)
);
}
return orFilterBuilder;
}
示例5: buildQuery
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
@Override
public FilterBuilder buildQuery(QueryNode queryNode) {
if (queryNode == null)
return null;
if (queryNode.getType().equals(QueryNodeType.BOOLEAN)) {
List<FilterBuilder> filterBuilders = new ArrayList<>();
for (QueryNode node : queryNode.getNodes()) {
filterBuilders.add(buildQuery(node));
}
if (queryNode.getOperator().equals(AND)) {
FilterBuilder andFilterBuilder = FilterBuilders.andFilter(filterBuilders.toArray(new FilterBuilder[filterBuilders.size()]));
return andFilterBuilder;
} else {
FilterBuilder orFilterBuilder = FilterBuilders.orFilter(filterBuilders.toArray(new FilterBuilder[filterBuilders.size()]));
return orFilterBuilder;
}
} else {
if (queryNode.getValue() != null && queryNode.getValue().getAttribute() != null) {
String key = ATT_PREFIX + Strings.slugify(queryNode.getValue().getAttribute().getCode()).replace(Char.MINUS, Char.UNDERSCORE) + HASH_SUFFIX;
if (queryNode.getValue().getOptionIds() != null && queryNode.getValue().getOptionIds().size() > 1) {
List<String> values = new ArrayList<>();
for (Id id : queryNode.getValue().getOptionIds()) {
values.add(Str.UNDERSCORE_2X + id + Str.UNDERSCORE_2X);
}
return FilterBuilders.termsFilter(key, values).execution(OR);
} else if (queryNode.getValue().getOptionIds() != null && queryNode.getValue().getOptionIds().size() > 0) {
return FilterBuilders.termsFilter(key, Str.UNDERSCORE_2X + queryNode.getValue().getOptionId() + Str.UNDERSCORE_2X);
} else if (queryNode.getValue().getVal() != null) {
if(queryNode.getValue().getAttribute().isAllowMultipleValues()){
key = ATT_PREFIX + Strings.slugify(queryNode.getValue().getAttribute().getCode()).replace(Char.MINUS, Char.UNDERSCORE) + RAW_SUFFIX;
return FilterBuilders.termsFilter(key, queryNode.getValue().getVal());
} else {
key = ATT_PREFIX + Strings.slugify(queryNode.getValue().getAttribute().getCode()).replace(Char.MINUS, Char.UNDERSCORE) + RAW_SUFFIX;
return FilterBuilders.termFilter(key, queryNode.getValue().getVal());
}
} else {
return FilterBuilders.missingFilter(key);
}
}
}
return null;
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:43,代码来源:DefaultProductListHelper.java
示例6: buildQuery
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
@Override
public FilterBuilder buildQuery(QueryNode queryNode) {
if (queryNode == null)
return null;
if (queryNode.getType().equals(QueryNodeType.BOOLEAN)) {
List<FilterBuilder> filterBuilders = new ArrayList<>();
if(queryNode.getNodes() != null) {
for (QueryNode node : queryNode.getNodes()) {
filterBuilders.add(buildQuery(node));
}
if (queryNode.getOperator().equals(AND)) {
FilterBuilder andFilterBuilder = FilterBuilders.andFilter(filterBuilders.toArray(new FilterBuilder[filterBuilders.size()]));
return andFilterBuilder;
} else {
FilterBuilder orFilterBuilder = FilterBuilders.orFilter(filterBuilders.toArray(new FilterBuilder[filterBuilders.size()]));
return orFilterBuilder;
}
}
} else {
if (queryNode.getValue() != null && queryNode.getValue().getAttribute() != null) {
String key = ATT_PREFIX + Strings.slugify(queryNode.getValue().getAttribute().getCode()).replace(Char.MINUS, Char.UNDERSCORE) + HASH_SUFFIX;
if (queryNode.getValue().getOptionIds() != null && queryNode.getValue().getOptionIds().size() > 1) {
List<String> values = new ArrayList<>();
for (Id id : queryNode.getValue().getOptionIds()) {
values.add(Str.UNDERSCORE_2X + id + Str.UNDERSCORE_2X);
}
return FilterBuilders.termsFilter(key, values).execution(OR);
} else if (queryNode.getValue().getOptionIds() != null && queryNode.getValue().getOptionIds().size() > 0) {
return FilterBuilders.termsFilter(key, Str.UNDERSCORE_2X + queryNode.getValue().getOptionId() + Str.UNDERSCORE_2X);
} else if (queryNode.getValue().getVal() != null) {
if(queryNode.getValue().getAttribute().isAllowMultipleValues()){
key = ATT_PREFIX + Strings.slugify(queryNode.getValue().getAttribute().getCode()).replace(Char.MINUS, Char.UNDERSCORE) + RAW_SUFFIX;
return FilterBuilders.termsFilter(key, queryNode.getValue().getVal());
} else {
if(StringUtils.isEmpty(queryNode.getComparator()) || "is".equals(queryNode.getComparator())){
key = ATT_PREFIX + Strings.slugify(queryNode.getValue().getAttribute().getCode()).replace(Char.MINUS, Char.UNDERSCORE) + RAW_SUFFIX;
return FilterBuilders.termFilter(key, queryNode.getValue().getVal());
} else {
key = ATT_PREFIX + Strings.slugify(queryNode.getValue().getAttribute().getCode()).replace(Char.MINUS, Char.UNDERSCORE) + RAW_SUFFIX;
if(queryNode.getComparator().equals("gt")){
return FilterBuilders.rangeFilter(key).gt(queryNode.getValue().getVal());
}
if(queryNode.getComparator().equals("gte")){
return FilterBuilders.rangeFilter(key).gte(queryNode.getValue().getVal());
}
if(queryNode.getComparator().equals("lt")){
return FilterBuilders.rangeFilter(key).lt(queryNode.getValue().getVal());
}
if(queryNode.getComparator().equals("lte")){
return FilterBuilders.rangeFilter(key).lte(queryNode.getValue().getVal());
}
}
}
} else {
return FilterBuilders.missingFilter(key);
}
}
}
return null;
}
示例7: getSpecificationsFacetFilterBuilder
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
private FilterBuilder getSpecificationsFacetFilterBuilder(SearchCriteria searchCriteria)
{
//This is used in case you want to search based on separate resolution/memory facets
Map<String, List<String>> multiSelectFilters = searchCriteria.getMultiSelectFilters();
List<String> resolutionFilters = new ArrayList<String>();
List<String> memoryFilters = new ArrayList<String>();
for (Entry<String, List<String>> entry : multiSelectFilters.entrySet())
{
if(entry.getKey().equals(SearchFacetName.SPECIFICATION_RESOLUTION.getCode()))
{
resolutionFilters.addAll(entry.getValue());
}
else if(entry.getKey().equals(SearchFacetName.SPECIFICATION_MEMORY.getCode()))
{
memoryFilters.addAll(entry.getValue());
}
}
if(resolutionFilters.size() == 0 && memoryFilters.size() == 0 )
{
return FilterBuilders.queryFilter(QueryBuilders.matchAllQuery());
}
AndFilterBuilder andResolutionAndMemoryFilterBuilder = FilterBuilders.andFilter();
if(resolutionFilters.size() > 0)
{
OrFilterBuilder OrResolutionFilterBuilder = FilterBuilders.orFilter();
for (String resolution : resolutionFilters)
{
OrResolutionFilterBuilder.add(FilterBuilders.termFilter(SearchDocumentFieldName.RESOLUTION.getFieldName(), resolution));
}
andResolutionAndMemoryFilterBuilder.add(OrResolutionFilterBuilder);
}
if(memoryFilters.size() > 0)
{
OrFilterBuilder OrMemoryFilterBuilder = FilterBuilders.orFilter();
for (String memory : memoryFilters)
{
OrMemoryFilterBuilder.add(FilterBuilders.termFilter(SearchDocumentFieldName.MEMORY.getFieldName(), memory));
}
andResolutionAndMemoryFilterBuilder.add(OrMemoryFilterBuilder);
}
// else if(specifications.size() == 1)
// {
// Specification specification = searchCriteria.getSpecifications().get(0);
//
// FilterBuilder filterBuilder = FilterBuilders.andFilter(FilterBuilders
// .termFilter(SearchDocumentFieldName.RESOLUTION.getFieldName(), specification.getResolution()),
// FilterBuilders.termFilter(SearchDocumentFieldName.MEMORY.getFieldName(), specification.getMemory()));
//
// specificationFilterBuilder = filterBuilder;
// }
// else
// {
// specificationFilterBuilder = FilterBuilders.matchAllFilter();
// }
return andResolutionAndMemoryFilterBuilder;
}
示例8: getSpecificationsFacetFilterBuilder
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
private FilterBuilder getSpecificationsFacetFilterBuilder(final SearchCriteria searchCriteria)
{
// This is used in case you want to search based on separate resolution/memory facets
final Map<String, List<String>> multiSelectFilters = searchCriteria.getMultiSelectFilters();
final List<String> resolutionFilters = new ArrayList<String>();
final List<String> memoryFilters = new ArrayList<String>();
for (final Entry<String, List<String>> entry : multiSelectFilters.entrySet())
{
if (entry.getKey().equals(SearchFacetName.SPECIFICATION_RESOLUTION.getCode()))
{
resolutionFilters.addAll(entry.getValue());
}
else if (entry.getKey().equals(SearchFacetName.SPECIFICATION_MEMORY.getCode()))
{
memoryFilters.addAll(entry.getValue());
}
}
if (resolutionFilters.size() == 0 && memoryFilters.size() == 0)
{
return FilterBuilders.queryFilter(QueryBuilders.matchAllQuery());
}
final AndFilterBuilder andResolutionAndMemoryFilterBuilder = FilterBuilders.andFilter();
if (resolutionFilters.size() > 0)
{
final OrFilterBuilder OrResolutionFilterBuilder = FilterBuilders.orFilter();
for (final String resolution : resolutionFilters)
{
OrResolutionFilterBuilder.add(FilterBuilders.termFilter(SearchDocumentFieldName.RESOLUTION.getFieldName(), resolution));
}
andResolutionAndMemoryFilterBuilder.add(OrResolutionFilterBuilder);
}
if (memoryFilters.size() > 0)
{
final OrFilterBuilder OrMemoryFilterBuilder = FilterBuilders.orFilter();
for (final String memory : memoryFilters)
{
OrMemoryFilterBuilder.add(FilterBuilders.termFilter(SearchDocumentFieldName.MEMORY.getFieldName(), memory));
}
andResolutionAndMemoryFilterBuilder.add(OrMemoryFilterBuilder);
}
// else if(specifications.size() == 1)
// {
// Specification specification = searchCriteria.getSpecifications().get(0);
//
// FilterBuilder filterBuilder = FilterBuilders.andFilter(FilterBuilders
// .termFilter(SearchDocumentFieldName.RESOLUTION.getFieldName(), specification.getResolution()),
// FilterBuilders.termFilter(SearchDocumentFieldName.MEMORY.getFieldName(), specification.getMemory()));
//
// specificationFilterBuilder = filterBuilder;
// }
// else
// {
// specificationFilterBuilder = FilterBuilders.matchAllFilter();
// }
return andResolutionAndMemoryFilterBuilder;
}
示例9: getSpecificationsFacetFilterBuilder
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
private FilterBuilder getSpecificationsFacetFilterBuilder(
final SearchCriteria searchCriteria) {
// This is used in case you want to search based on separate
// resolution/memory facets
final Map<String, List<String>> multiSelectFilters = searchCriteria
.getMultiSelectFilters();
final List<String> resolutionFilters = new ArrayList<String>();
final List<String> memoryFilters = new ArrayList<String>();
for (final Entry<String, List<String>> entry : multiSelectFilters
.entrySet()) {
if (entry.getKey().equals(
SearchFacetName.SPECIFICATION_RESOLUTION.getCode())) {
resolutionFilters.addAll(entry.getValue());
} else if (entry.getKey().equals(
SearchFacetName.SPECIFICATION_MEMORY.getCode())) {
memoryFilters.addAll(entry.getValue());
}
}
if (resolutionFilters.size() == 0 && memoryFilters.size() == 0) {
return FilterBuilders.queryFilter(QueryBuilders.matchAllQuery());
}
final AndFilterBuilder andResolutionAndMemoryFilterBuilder = FilterBuilders
.andFilter();
if (resolutionFilters.size() > 0) {
final OrFilterBuilder OrResolutionFilterBuilder = FilterBuilders
.orFilter();
for (final String resolution : resolutionFilters) {
OrResolutionFilterBuilder.add(FilterBuilders.termFilter(
SearchDocumentFieldName.RESOLUTION.getFieldName(),
resolution));
}
andResolutionAndMemoryFilterBuilder.add(OrResolutionFilterBuilder);
}
if (memoryFilters.size() > 0) {
final OrFilterBuilder OrMemoryFilterBuilder = FilterBuilders
.orFilter();
for (final String memory : memoryFilters) {
OrMemoryFilterBuilder.add(FilterBuilders.termFilter(
SearchDocumentFieldName.MEMORY.getFieldName(), memory));
}
andResolutionAndMemoryFilterBuilder.add(OrMemoryFilterBuilder);
}
// else if(specifications.size() == 1)
// {
// Specification specification =
// searchCriteria.getSpecifications().get(0);
//
// FilterBuilder filterBuilder = FilterBuilders.andFilter(FilterBuilders
// .termFilter(SearchDocumentFieldName.RESOLUTION.getFieldName(),
// specification.getResolution()),
// FilterBuilders.termFilter(SearchDocumentFieldName.MEMORY.getFieldName(),
// specification.getMemory()));
//
// specificationFilterBuilder = filterBuilder;
// }
// else
// {
// specificationFilterBuilder = FilterBuilders.matchAllFilter();
// }
return andResolutionAndMemoryFilterBuilder;
}