use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.BoolQueryBuilder in project gerrit by GerritCodeReview.
the class ElasticQueryBuilder method not.
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;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class SearchService method getDocumentListByDocIds.
public List<Map<String, Object>> getDocumentListByDocIds(final String[] docIds, final String[] fields, final OptionalThing<FessUserBean> userBean, final SearchRequestType searchRequestType) {
return fessEsClient.getDocumentList(fessConfig.getIndexDocumentSearchIndex(), fessConfig.getIndexDocumentType(), builder -> {
final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(fessConfig.getIndexFieldDocId(), docIds));
if (searchRequestType != SearchRequestType.ADMIN_SEARCH) {
final Set<String> roleSet = ComponentUtil.getRoleQueryHelper().build(searchRequestType);
if (!roleSet.isEmpty()) {
final BoolQueryBuilder roleQuery = QueryBuilders.boolQuery();
roleSet.stream().forEach(name -> {
roleQuery.should(QueryBuilders.termQuery(fessConfig.getIndexFieldRole(), name));
});
boolQuery.filter(roleQuery);
}
}
builder.setQuery(boolQuery);
builder.setSize(fessConfig.getPagingSearchPageMaxSizeAsInteger().intValue());
builder.setFetchSource(fields, null);
fessConfig.processSearchPreference(builder, userBean);
return true;
});
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class SearchService method getDocumentByDocId.
public OptionalEntity<Map<String, Object>> getDocumentByDocId(final String docId, final String[] fields, final OptionalThing<FessUserBean> userBean) {
return fessEsClient.getDocument(fessConfig.getIndexDocumentSearchIndex(), fessConfig.getIndexDocumentType(), builder -> {
final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().must(QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), docId));
final Set<String> roleSet = ComponentUtil.getRoleQueryHelper().build(SearchRequestType.JSON);
if (!roleSet.isEmpty()) {
final BoolQueryBuilder roleQuery = QueryBuilders.boolQuery();
roleSet.stream().forEach(name -> {
roleQuery.should(QueryBuilders.termQuery(fessConfig.getIndexFieldRole(), name));
});
boolQuery.filter(roleQuery);
}
builder.setQuery(boolQuery);
builder.setFetchSource(fields, null);
fessConfig.processSearchPreference(builder, userBean);
return true;
});
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class BsLabelToRoleCQ method bool.
public void bool(BoolCall<LabelToRoleCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
LabelToRoleCQ mustQuery = new LabelToRoleCQ();
LabelToRoleCQ shouldQuery = new LabelToRoleCQ();
LabelToRoleCQ mustNotQuery = new LabelToRoleCQ();
LabelToRoleCQ filterQuery = new LabelToRoleCQ();
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);
}
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class BsFileConfigToRoleCQ method bool.
public void bool(BoolCall<FileConfigToRoleCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
FileConfigToRoleCQ mustQuery = new FileConfigToRoleCQ();
FileConfigToRoleCQ shouldQuery = new FileConfigToRoleCQ();
FileConfigToRoleCQ mustNotQuery = new FileConfigToRoleCQ();
FileConfigToRoleCQ filterQuery = new FileConfigToRoleCQ();
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);
}
}
}
Aggregations