當前位置: 首頁>>代碼示例>>Java>>正文


Java BoolQueryBuilder.mustNot方法代碼示例

本文整理匯總了Java中org.elasticsearch.index.query.BoolQueryBuilder.mustNot方法的典型用法代碼示例。如果您正苦於以下問題:Java BoolQueryBuilder.mustNot方法的具體用法?Java BoolQueryBuilder.mustNot怎麽用?Java BoolQueryBuilder.mustNot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.index.query.BoolQueryBuilder的用法示例。


在下文中一共展示了BoolQueryBuilder.mustNot方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteAll

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
@Delete("/1/credentials")
@Delete("/1/credentials/")
public Payload deleteAll(Context context) {
	SpaceContext.checkSuperAdminCredentials();
	ElasticClient elastic = Start.get().getElasticClient();
	BoolQueryBuilder query = toQuery(context).query;

	// super admins can only be deleted when backend is deleted
	query.mustNot(QueryBuilders.termQuery(FIELD_CREDENTIALS_LEVEL, "SUPER_ADMIN"));
	elastic.deleteByQuery(SPACEDOG_BACKEND, query, TYPE);

	// allways refresh after credentials index updates
	elastic.refreshType(SPACEDOG_BACKEND, TYPE);

	return JsonPayload.success();
}
 
開發者ID:spacedog-io,項目名稱:spacedog-server,代碼行數:17,代碼來源:CredentialsResource.java

示例2: buildSearchQuery

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
/**
 * Method create's query for $search expression.
 * 
 * @param parentQuery
 *            parent bool query
 * @param expression
 *            search expression from query option
 */
private void buildSearchQuery(BoolQueryBuilder parentQuery, SearchExpression expression) {
    if (expression.isSearchBinary()) {
        SearchBinary binary = expression.asSearchBinary();
        BoolQueryBuilder leftBool = QueryBuilders.boolQuery();
        BoolQueryBuilder rightBool = QueryBuilders.boolQuery();
        SearchBinaryOperatorKind operatorKind = binary.getOperator();
        if (operatorKind == SearchBinaryOperatorKind.AND) {
            parentQuery.must(leftBool);
            parentQuery.must(rightBool);
        } else if (operatorKind == SearchBinaryOperatorKind.OR) {
            parentQuery.should(leftBool);
            parentQuery.should(rightBool);
        }
        buildSearchQuery(leftBool, binary.getLeftOperand());
        buildSearchQuery(rightBool, binary.getRightOperand());
    } else if (expression.isSearchUnary()) {
        SearchUnary unary = expression.asSearchUnary();
        parentQuery.mustNot(
                matchQuery(ElasticConstants.ALL_FIELD, unary.getOperand().getSearchTerm()));
    } else {
        parentQuery.must(matchQuery(ElasticConstants.ALL_FIELD,
                expression.asSearchTerm().getSearchTerm()));
    }
}
 
開發者ID:Hevelian,項目名稱:hevelian-olastic,代碼行數:33,代碼來源:RequestCreator.java

示例3: addIndexSearchFilterBooleanClause

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
/**
 * Navigates the specified index search filters and adds boolean filter clauses to a given {@link SearchRequestBuilder}
 *
 * @param indexSearchFilters the specified search filters
 * @param bdefActiveIndex the active bdef index name
 * @param tagActiveIndex the active tag index name
 *
 * @return boolean query with the filters applied
 */
public BoolQueryBuilder addIndexSearchFilterBooleanClause(List<IndexSearchFilter> indexSearchFilters, String bdefActiveIndex, String tagActiveIndex)
{
    BoolQueryBuilder compoundBoolQueryBuilder = new BoolQueryBuilder();
    for (IndexSearchFilter indexSearchFilter : indexSearchFilters)
    {
        BoolQueryBuilder indexSearchFilterClauseBuilder = applySearchFilterClause(indexSearchFilter, bdefActiveIndex, tagActiveIndex);

        // If the search filter is marked with the exclusion flag then apply the entire compound filter clause on the request builder within a MUST NOT
        // clause.
        if (BooleanUtils.isTrue(indexSearchFilter.isIsExclusionSearchFilter()))
        {
            compoundBoolQueryBuilder.mustNot(indexSearchFilterClauseBuilder);
        }
        else
        {
            // Individual search filters are AND-ed (the compound filter clause is applied on the search request builder within a MUST clause)
            compoundBoolQueryBuilder.must(indexSearchFilterClauseBuilder);
        }
    }

    return compoundBoolQueryBuilder;
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:32,代碼來源:ElasticsearchHelper.java

示例4: addQuery

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
private void addQuery(BoolQueryBuilder boolQuery, boolean positive, String query, String modifier) {
    if (Strings.isNullOrEmpty(query)) {
        return;
    }
    QueryStringQueryBuilder builder = QueryBuilders.queryStringQuery(query)
            .field("title." + modifier)
            .field("text." + modifier)
            .defaultOperator(Operator.AND);
    if (positive) {
        boolQuery.must(builder);
    } else {
        boolQuery.mustNot(builder);
    }
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:15,代碼來源:EsDocumentOperations.java

示例5: addAttributeToQueries

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
private static void addAttributeToQueries(List<QueryBuilder> queries, String attributeName, List<SearchQuery.AbstractAttributeQuery> attributeList) {

        BoolQueryBuilder attributeQueryBuilder = QueryBuilders.boolQuery();

        attributeQueryBuilder.must(QueryBuilders.nestedQuery(IndexerMapping.ATTRIBUTES_KEY,
                QueryBuilders.termQuery(IndexerMapping.ATTRIBUTES_KEY + "." + IndexerMapping.ATTRIBUTE_NAME, attributeName), ScoreMode.None));

        List<NestedQueryBuilder> nestedQueryBuilders = new ArrayList<>();
        BoolQueryBuilder valuesQuery = QueryBuilders.boolQuery();

        for (SearchQuery.AbstractAttributeQuery attr : attributeList) {
            String attributeValue = attr.toString();
            if (attributeValue != null && !attributeValue.isEmpty()) {
                nestedQueryBuilders.add(QueryBuilders.nestedQuery(IndexerMapping.ATTRIBUTES_KEY,
                        QueryBuilders.termQuery(IndexerMapping.ATTRIBUTES_KEY + "." + IndexerMapping.ATTRIBUTE_VALUE, attributeValue), ScoreMode.None));

            }
        }

        // Only request for attribute name if no values
        // Use bool must if only one value passed
        // Compound should queries if many values (but must not be empty)
        if (!nestedQueryBuilders.isEmpty()) {
            if (nestedQueryBuilders.size() == 1) {
                attributeQueryBuilder.must(nestedQueryBuilders.get(0));
            } else {
                nestedQueryBuilders.forEach(valuesQuery::should);
                attributeQueryBuilder.must(valuesQuery);
                attributeQueryBuilder.mustNot(QueryBuilders.nestedQuery(IndexerMapping.ATTRIBUTES_KEY,
                        QueryBuilders.termQuery(IndexerMapping.ATTRIBUTES_KEY + "." + IndexerMapping.ATTRIBUTE_VALUE, ""), ScoreMode.None));
            }
        }

        queries.add(attributeQueryBuilder);

    }
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:37,代碼來源:IndexerQueryBuilder.java

示例6: processNotSpecification

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
private void processNotSpecification( BoolQueryBuilder queryBuilder,
                                      Notpredicate spec,
                                      Map<String, Object> variables )
    throws EntityFinderException
{
    LOGGER.trace( "Processing NotSpecification {}", spec );
    BoolQueryBuilder operandBuilder = boolQuery();
    processSpecification( operandBuilder, spec.operand(), variables );
    queryBuilder.mustNot( operandBuilder );
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:11,代碼來源:ElasticSearchFinder.java

示例7: not

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
private <T> QueryBuilder not(Predicate<T> p) throws QueryParseException {
  Predicate<T> n = p.getChild(0);
  if (n instanceof TimestampRangePredicate) {
    return notTimestamp((TimestampRangePredicate<T>) n);
  }

  // Lucene does not support negation, start with all and subtract.
  BoolQueryBuilder q = QueryBuilders.boolQuery();
  q.must(QueryBuilders.matchAllQuery());
  q.mustNot(toQueryBuilder(n));
  return q;
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:13,代碼來源:ElasticQueryBuilder.java

示例8: buildAllThings

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
private QueryBuilder buildAllThings(String query, String motivations, String allDateRanges, String users,
    String type, String within) {
List<QueryBuilder> queryList = new ArrayList<>();

BoolQueryBuilder must = QueryBuilders.boolQuery();

if (null != query) {
    // String tidyQuery =
    // annotationUtils.convertSpecialCharacters(query);
    String tidyQuery = query;
    if (null == type) {
	must = must.must(QueryBuilders.multiMatchQuery(tidyQuery, "body", "target", "bodyURI", "targetURI")
		.type(Type.PHRASE));
    }
    if ("topic".equals(type)) {
	must = must.must(QueryBuilders.multiMatchQuery(tidyQuery, "bodyURI"));
    }
}

if (null != motivations) {
    List<String> motivationsList = annotationUtils.getListFromSpaceSeparatedTerms(motivations);
    if (motivations.contains("non-")) {

	if (motivationsList.size() > 1) {
	    throw new SearchQueryException(
		    "You have a motivation that is a non-<motivation>, there can only be one motivation in this instance.");
	} else {
	    String tidyMotivations = motivations.replaceAll("non-", "");
	    queryList.add(QueryBuilders.existsQuery(AnnotationSearchConstants.FIELD_MOTIVATIONS));

	    must.mustNot(QueryBuilders.termQuery(AnnotationSearchConstants.FIELD_MOTIVATIONS, tidyMotivations));
	}
    } else {
	must.filter(QueryBuilders.termsQuery(AnnotationSearchConstants.FIELD_MOTIVATIONS, motivationsList));
    }
}

if (null != allDateRanges) {
    queryList.add(buildDates("created", allDateRanges));
}

if (null != users) {
    List<String> usersList = annotationUtils.getListFromSpaceSeparatedTerms(users);
    must.filter(QueryBuilders.termsQuery("creators", usersList));
}

for (QueryBuilder eachQuery : queryList) {
    must = must.must(eachQuery);
}

if (null != within) {
    String decodedWithinUrl = annotationUtils.decodeWithinUrl(within);
    if (null != decodedWithinUrl) {
	must.must(QueryBuilders.matchQuery("manifest", decodedWithinUrl));
    }
}

return must;
   }
 
開發者ID:dlcs,項目名稱:the-mathmos-server,代碼行數:60,代碼來源:AnnotationSearchServiceImpl.java

示例9: processPropertyNullSpecification

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
private void processPropertyNullSpecification( BoolQueryBuilder queryBuilder,
                                               PropertyNullPredicate<?> spec )
{
    LOGGER.trace( "Processing PropertyNullSpecification {}", spec );
    queryBuilder.mustNot( existsQuery( ( spec.property().toString() ) ) );
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:7,代碼來源:ElasticSearchFinder.java

示例10: processAssociationNullSpecification

import org.elasticsearch.index.query.BoolQueryBuilder; //導入方法依賴的package包/類
private void processAssociationNullSpecification( BoolQueryBuilder queryBuilder,
                                                  AssociationNullPredicate<?> spec )
{
    LOGGER.trace( "Processing AssociationNullSpecification {}", spec );
    queryBuilder.mustNot( existsQuery( ( spec.association().toString() + ".identity" ) ) );
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:7,代碼來源:ElasticSearchFinder.java


注:本文中的org.elasticsearch.index.query.BoolQueryBuilder.mustNot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。