use of 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.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class EsAbstractConditionQuery method regBoolCQ.
protected BoolQueryBuilder regBoolCQ(List<QueryBuilder> mustList, List<QueryBuilder> shouldList, List<QueryBuilder> mustNotList, List<QueryBuilder> filterList) {
assertObjectNotNull("mustList", mustList);
assertObjectNotNull("shouldList", shouldList);
assertObjectNotNull("mustNotList", mustNotList);
assertObjectNotNull("filterList", filterList);
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
mustList.forEach(query -> {
boolQuery.must(query);
});
shouldList.forEach(query -> {
boolQuery.should(query);
});
mustNotList.forEach(query -> {
boolQuery.mustNot(query);
});
filterList.forEach(query -> {
boolQuery.filter(query);
});
regQ(boolQuery);
return boolQuery;
}
use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class EsAbstractConditionQuery method getQuery.
public QueryBuilder getQuery() {
if (queryBuilderList == null) {
return null;
} else if (queryBuilderList.size() == 1) {
return queryBuilderList.get(0);
}
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
queryBuilderList.forEach(query -> {
boolQuery.must(query);
});
return boolQuery;
}
use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class BsAccessTokenCQ method bool.
public void bool(BoolCall<AccessTokenCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
AccessTokenCQ mustQuery = new AccessTokenCQ();
AccessTokenCQ shouldQuery = new AccessTokenCQ();
AccessTokenCQ mustNotQuery = new AccessTokenCQ();
AccessTokenCQ filterQuery = new AccessTokenCQ();
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.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class BsBoostDocumentRuleCQ method bool.
public void bool(BoolCall<BoostDocumentRuleCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
BoostDocumentRuleCQ mustQuery = new BoostDocumentRuleCQ();
BoostDocumentRuleCQ shouldQuery = new BoostDocumentRuleCQ();
BoostDocumentRuleCQ mustNotQuery = new BoostDocumentRuleCQ();
BoostDocumentRuleCQ filterQuery = new BoostDocumentRuleCQ();
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