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


Java BoolFilterBuilder.must方法代码示例

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


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

示例1: addFilters

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
protected void addFilters(BoolFilterBuilder boolFilter) {
    Map<String, Filter> filters = query.getFilters();
    if (filters != null) {
        for (Filter filter : filters.values()) {
            FilterBuilder filterBuilder = converterFilter(filter);
            if (filterBuilder != null) {
                switch (filter.getClause()) {
                    case SHOULD:
                        boolFilter.should(filterBuilder);
                        break;
                    case MUST_NOT:
                        boolFilter.mustNot(filterBuilder);
                        break;
                    case MUST:
                    default:
                        boolFilter.must(filterBuilder);
                }
            }
        }
    }
}
 
开发者ID:scaleset,项目名称:scaleset-search,代码行数:22,代码来源:DefaultQueryConverter.java

示例2: addFilterForTopicId

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:18,代码来源:FiltersBuilder.java

示例3: addSubFilter

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
/**
 * 增加嵌套插
 * 
 * @param boolFilter
 * @param where
 * @param subFilter
 */
private void addSubFilter(BoolFilterBuilder boolFilter, Where where, BaseFilterBuilder subFilter) {
	if (where.getConn() == CONN.AND) {
		boolFilter.must(subFilter);
	} else {
		boolFilter.should(subFilter);
	}
}
 
开发者ID:lane-cn,项目名称:elasticsql,代码行数:15,代码来源:FilterMaker.java

示例4: addQ

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
protected void addQ(SearchRequestBuilder builder, BoolFilterBuilder boolFilter) {
    if (types.length > 0) {
        builder.setTypes(types);
    }
    if (query.getQ() != null && !query.getQ().isEmpty()) {
        boolFilter.must(queryFilter(queryString(query.getQ()).defaultOperator(Operator.AND)));
    }
}
 
开发者ID:scaleset,项目名称:scaleset-search,代码行数:9,代码来源:DefaultQueryConverter.java

示例5: addBbox

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
protected void addBbox(BoolFilterBuilder boolFilter) {
    Envelope bbox = query.getBbox();
    String geoField = query.getGeoField();
    if ((geoField != null && !geoField.isEmpty()) && (bbox != null)) {
        boolFilter.must(geoBoundingBoxFilter(geoField).bottomLeft(bbox.getMinY(), bbox.getMinX()).topRight(bbox.getMaxY(), bbox.getMaxX()));
    }
}
 
开发者ID:scaleset,项目名称:scaleset-search,代码行数:8,代码来源:DefaultQueryConverter.java

示例6: createFrequentlyRelatedContentSearch

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
public SearchSourceBuilder createFrequentlyRelatedContentSearch(RelatedItemSearch search) {

        SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
        String id = search.getRelatedItemId();

        BoolFilterBuilder b = FilterBuilders.boolFilter();
        b.must(FilterBuilders.termFilter(relatedWithAttribute, id));


        RelatedItemAdditionalProperties searchProps = search.getAdditionalSearchCriteria();
        int numberOfProps = searchProps.getNumberOfProperties();

        for(int i = 0;i<numberOfProps;i++) {
            b.must(FilterBuilders.termFilter(searchProps.getPropertyName(i), searchProps.getPropertyValue(i)));
        }
        ConstantScoreQueryBuilder cs = QueryBuilders.constantScoreQuery(b);


        TermsFacetBuilder facetBuilder = FacetBuilders.termsFacet(facetResultName).field(itemIdentifierAttribute).size(search.getMaxResults());
        if(hasExecutionHint) {
            facetBuilder.executionHint(executionHint);
        }


        sourceBuilder.size(0);
        sourceBuilder.query(cs);
        sourceBuilder.timeout(searchTimeoutValue);
        sourceBuilder.facet(facetBuilder);
        log.debug("Frequently Related Query Built: {}",sourceBuilder);
        return sourceBuilder;

    }
 
开发者ID:tootedom,项目名称:related,代码行数:33,代码来源:FrequentRelatedSearchRequestBuilder.java

示例7: addBrandId

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
private void addBrandId(
        IndexQueryParams queryParams,
        BoolFilterBuilder filterBuilder
) {
    if (queryParams.getBrandId().isPresent()) {
        filterBuilder.must(
                FiltersBuilder.getBrandIdFilter(
                        queryParams.getBrandId().get(),
                        equivIdIndex
                )
        );
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:14,代码来源:EsUnequivalentContentIndex.java

示例8: addSeriesId

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
private void addSeriesId(
        IndexQueryParams queryParams,
        BoolFilterBuilder filterBuilder
) {
    if (queryParams.getSeriesId().isPresent()) {
        filterBuilder.must(
                FiltersBuilder.getSeriesIdFilter(
                        queryParams.getSeriesId().get(), equivIdIndex
                )
        );
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:13,代码来源:EsUnequivalentContentIndex.java

示例9: addTopicFilter

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
private void addTopicFilter(
        IndexQueryParams queryParams,
        BoolFilterBuilder filterBuilder
) {
    if (queryParams.getTopicFilterIds().isPresent()) {
        filterBuilder.must(
                FiltersBuilder.buildTopicIdFilter(queryParams.getTopicFilterIds().get())
        );
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:11,代码来源:EsUnequivalentContentIndex.java

示例10: addActionableFilter

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
private void addActionableFilter(
        IndexQueryParams queryParams,
        BoolFilterBuilder filterBuilder
) {
    if (queryParams.getActionableFilterParams().isPresent()) {
        Optional<Id> maybeRegionId = queryParams.getRegionId();
        FilterBuilder actionableFilter = FiltersBuilder.buildActionableFilter(
                queryParams.getActionableFilterParams().get(),
                maybeRegionId,
                channelGroupResolver
        );
        filterBuilder.must(actionableFilter);
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:15,代码来源:EsUnequivalentContentIndex.java

示例11: prepareBoolFilterBuilder

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
/**
 * This method prepares a Boolean filter builder with respective facet selections from Resource request object.
 *
 * @param request the request
 * @return the bool filter builder
 */
private BoolFilterBuilder prepareBoolFilterBuilder(ResourceRequest request) {
    
    /**Set a filter to get suggestions with Status Approved (0) */
    BoolFilterBuilder boolFilterBuilder = FilterBuilders.boolFilter()
            .must(FilterBuilders.termFilter(ElasticsearchPortletConstants.STATUS, 
                    WorkflowConstants.STATUS_APPROVED));
    
    /** Iterate over Suggestion excluded index types and add to Boolfilter. Since these are excluded, mustNot filter should be used */
    for (Iterator<String> iterator = propsValues.getSuggestionExcludedTypes().iterator(); iterator.hasNext();) {
        boolFilterBuilder.mustNot(FilterBuilders.typeFilter(iterator.next()));
    } 
    
    /** Process facet selections and apply appropriate filters here
        Apply UserId filter */
    long userId = ParamUtil.getLong(request, WorkflowConstants.CONTEXT_USER_ID);
    if(userId > ElasticsearchPortletConstants.INTEGER_ZERO_VALUE) {
        boolFilterBuilder.must(FilterBuilders.termFilter(WorkflowConstants.CONTEXT_USER_ID, userId));
    }

    /** Apply modified filter */
    String selectedRange = ParamUtil.getString(request, ElasticsearchPortletConstants.FILTER_MODIFIED);
    if(Validator.isNotNull(selectedRange) && !selectedRange.isEmpty()){
        String[] rangeArray = fetchFromToValuesInRage(selectedRange);
        boolFilterBuilder.must(FilterBuilders.rangeFilter(ElasticsearchPortletConstants.FILTER_MODIFIED_DATE)
                                .from(rangeArray[0].trim()).to(rangeArray[1].trim()));
    }
    
    /**  Apply AssetCategoryIds filter */
    long assetCategoryIds = ParamUtil.getLong(request, ElasticsearchPortletConstants.FILTER_ASSET_CATEGORY);
    if(assetCategoryIds > ElasticsearchPortletConstants.INTEGER_ZERO_VALUE) {
        boolFilterBuilder.must(FilterBuilders.termFilter(ElasticsearchPortletConstants.FILTER_ASSET_CATEGORY, assetCategoryIds));
    }


    /**  Apply FolderId filter */
    long folderId = ParamUtil.getLong(request, ElasticsearchPortletConstants.FILTER_FOLDERID);
    if(folderId > ElasticsearchPortletConstants.INTEGER_ZERO_VALUE) {
        boolFilterBuilder.must(FilterBuilders.termFilter(ElasticsearchPortletConstants.FILTER_FOLDERID, folderId));
    }

    /** Apply Site id filter */
    long groupId = ParamUtil.getLong(request, WorkflowConstants.CONTEXT_GROUP_ID);
    if(groupId != WorkflowConstants.DEFAULT_GROUP_ID){
        boolFilterBuilder.must(FilterBuilders.termFilter(ElasticsearchPortletConstants.FILTER_SCOPE_GROUPID, groupId))
                         .must(FilterBuilders.termFilter(WorkflowConstants.CONTEXT_GROUP_ID, groupId));
    }

    /**  Entryclassname is a special case since object is directly mapped to Index type in Elasticsearch.
     So instead of applying a filter, we use respective Entryclassname type */
    String selectedClassName = ParamUtil.getString(request, ElasticsearchPortletConstants.ENTRY_CLASSNAME);
    if(Validator.isNotNull(selectedClassName)){
        /** Convert selectedClassName to index type by replacing . with _*/
        selectedClassName = selectedClassName.replace(StringPool.PERIOD, StringPool.UNDERLINE);
        boolFilterBuilder.must(FilterBuilders.typeFilter(selectedClassName));
    }
    return boolFilterBuilder;
}
 
开发者ID:rivetlogic,项目名称:liferay-elasticsearch-integration,代码行数:64,代码来源:ElasticsearchPortletHelper.java

示例12: createFilterBuilder

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
/**
 * Create our filter builder.  We need to restrict our results on edge search, as well as on types, and any filters
 * that came from the grammar.
 */
private FilterBuilder createFilterBuilder( final SearchEdge searchEdge, final QueryVisitor visitor,
                                           final SearchTypes searchTypes ) {
    String context = createContextName( applicationScope, searchEdge );


    // Add our filter for context to our query for fast execution.
    // Fast because it utilizes bitsets internally. See this post for more detail.
    // http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/

    // TODO evaluate performance when it's an all query.
    // Do we need to put the context term first for performance?

    //make sure we have entity in the context
    BoolFilterBuilder boolQueryFilter = FilterBuilders.boolFilter();

    //add our edge search
    boolQueryFilter.must( FilterBuilders.termFilter( IndexingUtils.EDGE_SEARCH_FIELDNAME, context ) );


    /**
     * For the types the user specified, add them to an OR so 1 of them must match
     */
    final String[] sourceTypes = searchTypes.getTypeNames( applicationScope );


    if ( sourceTypes.length > 0 ) {
        final FilterBuilder[] typeTerms = new FilterBuilder[sourceTypes.length];

        for ( int i = 0; i < sourceTypes.length; i++ ) {
            typeTerms[i] = FilterBuilders.termFilter( IndexingUtils.ENTITY_TYPE_FIELDNAME, sourceTypes[i] );
        }

        //add all our types, 1 type must match per query
        boolQueryFilter.must( FilterBuilders.orFilter( typeTerms ) );
    }

    //if we have a filter from our visitor, add it

    Optional<FilterBuilder> queryBuilder = visitor.getFilterBuilder();

    if ( queryBuilder.isPresent() ) {
        boolQueryFilter.must( queryBuilder.get() );
    }

    return boolQueryFilter;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:51,代码来源:SearchRequestBuilderStrategy.java

示例13: getAuditLog

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
@GET
@Path("/auditlog")
@Produces(MediaType.APPLICATION_JSON)
@AuditIgnore
public StreamingOutput getAuditLog(
		@QueryParam("operation") String operation,
		@QueryParam("path") String path,
		@QueryParam("username") String username,
		@QueryParam("usertype") String usertype,
		@QueryParam("id") String id,
		@QueryParam("from") Integer from,
		@QueryParam("size") Integer size,
		@QueryParam("sort") String sort) throws IOException {


	BoolFilterBuilder filterBuilder = FilterBuilders.boolFilter();
	boolean filterAdded = false;
	if (StringUtils.isNotBlank(path)) {
		filterAdded = true;
		filterBuilder.must(FilterBuilders.prefixFilter("path", path));
	}


	if (StringUtils.isNotBlank(operation)) {
		filterAdded = true;
		filterBuilder.must(FilterBuilders.termFilter("operation", operation));
	}
	if (StringUtils.isNotBlank(username)) {
		filterAdded = true;
		filterBuilder.must(FilterBuilders.termFilter("username", username));
	}
	if (StringUtils.isNotBlank(usertype)) {
		filterAdded = true;
		filterBuilder.must(FilterBuilders.termFilter("usertype", usertype));
	}
	if (StringUtils.isNotBlank(id)) {
		filterAdded = true;
		filterBuilder.must(FilterBuilders.termFilter("id", id));
	}
	if (!filterAdded) {
		filterBuilder = null;
	}

	try {
		SearchResponse response = statsClientService.performSearch(StatsRecordType.AUDIT, filterBuilder, from, size, sort);
		return new ESDataOnlyResponse(response);
	} catch (SearchIndexMissingException e) {
		return null;
	}
}
 
开发者ID:searchisko,项目名称:searchisko,代码行数:51,代码来源:SystemRestService.java

示例14: fieldNameTerm

import org.elasticsearch.index.query.BoolFilterBuilder; //导入方法依赖的package包/类
/**
 * 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 );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:15,代码来源:EsQueryVistor.java


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