本文整理汇总了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: 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()));
}
}
示例2: 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;
}
示例3: 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();
}
示例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);
}
}
示例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);
}
示例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 );
}
示例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;
}
示例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;
}
示例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() ) ) );
}
示例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" ) ) );
}