本文整理汇总了Java中org.elasticsearch.index.query.FilterBuilders.queryFilter方法的典型用法代码示例。如果您正苦于以下问题:Java FilterBuilders.queryFilter方法的具体用法?Java FilterBuilders.queryFilter怎么用?Java FilterBuilders.queryFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.index.query.FilterBuilders
的用法示例。
在下文中一共展示了FilterBuilders.queryFilter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTraceCompletionCount
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
private long getTraceCompletionCount(String tenantId, Criteria criteria, boolean onlyFaulty) {
String index = client.getIndex(tenantId);
if (!refresh(index)) {
return 0;
}
BoolQueryBuilder query = buildQuery(criteria, ElasticsearchUtil.TRANSACTION_FIELD, CompletionTime.class);
SearchRequestBuilder request = getTraceCompletionRequest(index, criteria, query, 0);
if (onlyFaulty) {
FilterBuilder filter = FilterBuilders.queryFilter(QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery(ElasticsearchUtil.PROPERTIES_NAME_FIELD, Constants.PROP_FAULT)));
request.setPostFilter(FilterBuilders.nestedFilter("properties", filter));
}
SearchResponse response = request.execute().actionGet();
if (response.isTimedOut()) {
msgLog.warnQueryTimedOut();
return 0;
} else {
return response.getHits().getTotalHits();
}
}
示例2: fromValueType
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
private static FilterBuilder fromValueType(String field, String value, int valueType){
if(value.contains("*") || value.contains("?")){
if( value.length() > 1 && value.indexOf('*') == (value.length()-1))
return FilterBuilders.prefixFilter(field, value.substring(0, value.length()-1));
else
return FilterBuilders.queryFilter(QueryBuilders.wildcardQuery(field, value));
}
switch(valueType){
case AST_TermExpression.TERM:
return FilterBuilders.termFilter(field, value);
case AST_TermExpression.PHRASE:
/*for(byte b: value.getBytes()){
System.out.printf("0x%02X ", b);
}*/
return FilterBuilders.queryFilter(QueryBuilders.matchPhraseQuery(field, value));
}
return null;
}
示例3: 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;
}
示例4: 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;
}
示例5: addFilter
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
public ElasticSearchPlaceQuery addFilter(String filterQuery) {
QueryFilterBuilder filterBuilder = FilterBuilders.queryFilter(QueryBuilders.queryString(filterQuery));
queryBuilder = QueryBuilders.filteredQuery(queryBuilder, filterBuilder);
return this;
}
示例6: 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;
}