当前位置: 首页>>代码示例>>Java>>正文


Java FilterBuilders.rangeFilter方法代码示例

本文整理汇总了Java中org.elasticsearch.index.query.FilterBuilders.rangeFilter方法的典型用法代码示例。如果您正苦于以下问题:Java FilterBuilders.rangeFilter方法的具体用法?Java FilterBuilders.rangeFilter怎么用?Java FilterBuilders.rangeFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.index.query.FilterBuilders的用法示例。


在下文中一共展示了FilterBuilders.rangeFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rangeFilter

import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
public FilterBuilder rangeFilter(String name) {
	FilterBuilder filter = null;
	
	if(max.isPresent() && max.get() == 0) {
		filter = FilterBuilders.notFilter(FilterBuilders.existsFilter(name));
	} else {
		RangeFilterBuilder rfilter = FilterBuilders.rangeFilter(name);
		min.ifPresent(m -> rfilter.from(m));
		max.ifPresent(m -> rfilter.to(m));
		filter = rfilter;
	}
	
	return filter;
}
 
开发者ID:thirdy,项目名称:blackmarket,代码行数:15,代码来源:RangeOptional.java

示例2: buildSingleRangeFilter

import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
private FilterBuilder buildSingleRangeFilter(String key, String value) {
    String[] values = value.split(" - ");
    if (value.length() == 0) {
        return null;
    }
    RangeFilterBuilder filterBuilder = FilterBuilders.rangeFilter(key);
    if (value.length() == 2) {
        filterBuilder.from(Double.valueOf(values[0]).doubleValue()).to(Double.valueOf(values[1]));
    } else if (value.startsWith(values[0])) {
        filterBuilder.gte(Double.valueOf(values[0]).doubleValue());
    } else {
        filterBuilder.lt(Double.valueOf(values[0]).doubleValue());
    }
    return filterBuilder;
}
 
开发者ID:alien4cloud,项目名称:elasticsearch-mapping-parent,代码行数:16,代码来源:RangeFilterBuilderHelper.java

示例3: buildQuery

import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
@Override
public QueryBuilder buildQuery(List<FilterBuilder> builders, Map<String, FilterValue> filterParams) {
    List<FilterBuilder> filterBuilders = new ArrayList<>();

    if(filterParams != null) {
        for (String key : filterParams.keySet()) {
            FilterValue filterValue = filterParams.get(key);
            FilterType filterType = filterValue.getFilterType();
            Set<Object> value = filterValue.getValues();

            if (filterType == FilterType.RANGE) {
                RangeFilterBuilder rangeFilterBuilder = FilterBuilders.rangeFilter(key);

                Object[] values = value.toArray();

                if (value.size() > 1) {
                    rangeFilterBuilder.from(Double.parseDouble((String) values[0]));
                    rangeFilterBuilder.to(Double.parseDouble((String) values[1]));
                } else if (value.size() > 0) {
                    rangeFilterBuilder.from(Double.parseDouble((String) values[0]));
                } else {
                    rangeFilterBuilder.from(0);
                }

                filterBuilders.add(rangeFilterBuilder);
            } else {
                if (value.size() > 1) {
                    filterBuilders.add(FilterBuilders.termsFilter(key, value.toArray()).execution("or"));
                } else if (value.size() > 0) {
                    filterBuilders.add(FilterBuilders.termsFilter(key, value.iterator().next()));
                }
            }

        }
    }

    if (builders != null && !builders.isEmpty())
        filterBuilders.addAll(builders);

    if(filterBuilders.size() > 1){
        FilterBuilder andFilterBuilder = FilterBuilders
                .andFilter(filterBuilders.toArray(new FilterBuilder[filterBuilders.size()]));

        return QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), andFilterBuilder);
    } else {
        return QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), filterBuilders.get(0));
    }

}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:50,代码来源:DefaultElasticsearchHelper.java


注:本文中的org.elasticsearch.index.query.FilterBuilders.rangeFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。