Search in sources :

Example 46 with BoolQueryBuilder

use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.

the class BsSearchLogCQ method bool.

public void bool(BoolCall<SearchLogCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
    SearchLogCQ mustQuery = new SearchLogCQ();
    SearchLogCQ shouldQuery = new SearchLogCQ();
    SearchLogCQ mustNotQuery = new SearchLogCQ();
    SearchLogCQ filterQuery = new SearchLogCQ();
    boolLambda.callback(mustQuery, shouldQuery, mustNotQuery, filterQuery);
    if (mustQuery.hasQueries() || shouldQuery.hasQueries() || mustNotQuery.hasQueries() || filterQuery.hasQueries()) {
        BoolQueryBuilder builder = regBoolCQ(mustQuery.getQueryBuilderList(), shouldQuery.getQueryBuilderList(), mustNotQuery.getQueryBuilderList(), filterQuery.getQueryBuilderList());
        if (opLambda != null) {
            opLambda.callback(builder);
        }
    }
}
Also used : BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) SearchLogCQ(org.codelibs.fess.es.log.cbean.cq.SearchLogCQ)

Example 47 with BoolQueryBuilder

use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.

the class BsGroupCQ method bool.

public void bool(BoolCall<GroupCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
    GroupCQ mustQuery = new GroupCQ();
    GroupCQ shouldQuery = new GroupCQ();
    GroupCQ mustNotQuery = new GroupCQ();
    GroupCQ filterQuery = new GroupCQ();
    boolLambda.callback(mustQuery, shouldQuery, mustNotQuery, filterQuery);
    if (mustQuery.hasQueries() || shouldQuery.hasQueries() || mustNotQuery.hasQueries() || filterQuery.hasQueries()) {
        BoolQueryBuilder builder = regBoolCQ(mustQuery.getQueryBuilderList(), shouldQuery.getQueryBuilderList(), mustNotQuery.getQueryBuilderList(), filterQuery.getQueryBuilderList());
        if (opLambda != null) {
            opLambda.callback(builder);
        }
    }
}
Also used : BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) GroupCQ(org.codelibs.fess.es.user.cbean.cq.GroupCQ)

Example 48 with BoolQueryBuilder

use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.

the class BsRoleCQ method bool.

public void bool(BoolCall<RoleCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
    RoleCQ mustQuery = new RoleCQ();
    RoleCQ shouldQuery = new RoleCQ();
    RoleCQ mustNotQuery = new RoleCQ();
    RoleCQ filterQuery = new RoleCQ();
    boolLambda.callback(mustQuery, shouldQuery, mustNotQuery, filterQuery);
    if (mustQuery.hasQueries() || shouldQuery.hasQueries() || mustNotQuery.hasQueries() || filterQuery.hasQueries()) {
        BoolQueryBuilder builder = regBoolCQ(mustQuery.getQueryBuilderList(), shouldQuery.getQueryBuilderList(), mustNotQuery.getQueryBuilderList(), filterQuery.getQueryBuilderList());
        if (opLambda != null) {
            opLambda.callback(builder);
        }
    }
}
Also used : BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) RoleCQ(org.codelibs.fess.es.user.cbean.cq.RoleCQ)

Example 49 with BoolQueryBuilder

use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.

the class SuggestHelper method purgeSearchlogSuggest.

public void purgeSearchlogSuggest(final LocalDateTime time) {
    final BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
    boolQueryBuilder.must(QueryBuilders.rangeQuery(FieldNames.TIMESTAMP).lt(time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
    boolQueryBuilder.mustNot(QueryBuilders.termQuery(FieldNames.KINDS, SuggestItem.Kind.DOCUMENT.toString()));
    boolQueryBuilder.must(QueryBuilders.termQuery(FieldNames.KINDS, SuggestItem.Kind.QUERY.toString()));
    boolQueryBuilder.mustNot(QueryBuilders.termQuery(FieldNames.KINDS, SuggestItem.Kind.USER.toString()));
    SuggestUtil.deleteByQuery(fessEsClient, suggester.getIndex(), suggester.getType(), boolQueryBuilder);
}
Also used : BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder)

Example 50 with BoolQueryBuilder

use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.

the class QueryHelper method buildRoleQuery.

protected void buildRoleQuery(final QueryContext queryContext, final SearchRequestType searchRequestType) {
    if (roleQueryHelper != null && queryContext.roleQueryEnabled()) {
        final Set<String> roleSet = roleQueryHelper.build(searchRequestType);
        if (!roleSet.isEmpty()) {
            queryContext.addQuery(boolQuery -> {
                final BoolQueryBuilder roleQuery = QueryBuilders.boolQuery();
                roleSet.stream().forEach(name -> {
                    roleQuery.should(QueryBuilders.termQuery(fessConfig.getIndexFieldRole(), name));
                });
                boolQuery.filter(roleQuery);
            });
        }
    }
}
Also used : BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder)

Aggregations

BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)98 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)25 SearchResponse (org.elasticsearch.action.search.SearchResponse)15 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)9 MatchQueryBuilder (org.elasticsearch.index.query.MatchQueryBuilder)9 HasParentQueryBuilder (org.elasticsearch.index.query.HasParentQueryBuilder)8 ElasticsearchAssertions.assertSearchResponse (org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)5 MatchAllQueryBuilder (org.elasticsearch.index.query.MatchAllQueryBuilder)5 RangeQueryBuilder (org.elasticsearch.index.query.RangeQueryBuilder)5 Map (java.util.Map)4 AbstractAggregationBuilder (org.elasticsearch.search.aggregations.AbstractAggregationBuilder)4 FilterAggregationBuilder (org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder)4 FieldSortBuilder (org.elasticsearch.search.sort.FieldSortBuilder)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 StickyFacetBuilder (org.sonar.server.es.StickyFacetBuilder)4 HasChildQueryBuilder (org.elasticsearch.index.query.HasChildQueryBuilder)3 InnerHitBuilder (org.elasticsearch.index.query.InnerHitBuilder)3