use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class QueryHelper method buildDefaultQueryBuilder.
private QueryBuilder buildDefaultQueryBuilder(final DefaultQueryBuilderFunction builder) {
final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
final QueryBuilder titleQuery = builder.apply(fessConfig.getIndexFieldTitle(), fessConfig.getQueryBoostTitleAsDecimal().floatValue());
boolQuery.should(titleQuery);
final QueryBuilder contentQuery = builder.apply(fessConfig.getIndexFieldContent(), fessConfig.getQueryBoostContentAsDecimal().floatValue());
boolQuery.should(contentQuery);
getQueryLanguages().ifPresent(langs -> {
stream(langs).of(stream -> stream.forEach(lang -> {
final QueryBuilder titleLangQuery = builder.apply(fessConfig.getIndexFieldTitle() + "_" + lang, fessConfig.getQueryBoostTitleLangAsDecimal().floatValue());
boolQuery.should(titleLangQuery);
final QueryBuilder contentLangQuery = builder.apply(fessConfig.getIndexFieldContent() + "_" + lang, fessConfig.getQueryBoostContentLangAsDecimal().floatValue());
boolQuery.should(contentLangQuery);
}));
});
return boolQuery;
}
use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class KeyMatchHelper method reload.
protected void reload(final long interval) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final KeyMatchService keyMatchService = ComponentUtil.getComponent(KeyMatchService.class);
final Map<String, Pair<QueryBuilder, ScoreFunctionBuilder>> keyMatchQueryMap = new HashMap<>();
keyMatchService.getAvailableKeyMatchList().stream().forEach(keyMatch -> {
final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
getDocumentList(keyMatch).stream().map(doc -> {
return DocumentUtil.getValue(doc, fessConfig.getIndexFieldDocId(), String.class);
}).forEach(docId -> {
boolQuery.should(QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), docId));
});
if (boolQuery.hasClauses()) {
keyMatchQueryMap.put(toLowerCase(keyMatch.getTerm()), new Pair<>(boolQuery, ScoreFunctionBuilders.weightFactorFunction(keyMatch.getBoost())));
}
if (reloadInterval > 0) {
try {
Thread.sleep(reloadInterval);
} catch (final InterruptedException e) {
if (logger.isDebugEnabled()) {
logger.debug("Interrupted.", e);
}
}
}
});
this.keyMatchQueryMap = keyMatchQueryMap;
}
use of org.elasticsearch.index.query.BoolQueryBuilder in project fess by codelibs.
the class BsDataConfigToRoleCQ method bool.
public void bool(BoolCall<DataConfigToRoleCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
DataConfigToRoleCQ mustQuery = new DataConfigToRoleCQ();
DataConfigToRoleCQ shouldQuery = new DataConfigToRoleCQ();
DataConfigToRoleCQ mustNotQuery = new DataConfigToRoleCQ();
DataConfigToRoleCQ filterQuery = new DataConfigToRoleCQ();
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 BsElevateWordCQ method bool.
public void bool(BoolCall<ElevateWordCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
ElevateWordCQ mustQuery = new ElevateWordCQ();
ElevateWordCQ shouldQuery = new ElevateWordCQ();
ElevateWordCQ mustNotQuery = new ElevateWordCQ();
ElevateWordCQ filterQuery = new ElevateWordCQ();
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 BsRequestHeaderCQ method bool.
public void bool(BoolCall<RequestHeaderCQ> boolLambda, ConditionOptionCall<BoolQueryBuilder> opLambda) {
RequestHeaderCQ mustQuery = new RequestHeaderCQ();
RequestHeaderCQ shouldQuery = new RequestHeaderCQ();
RequestHeaderCQ mustNotQuery = new RequestHeaderCQ();
RequestHeaderCQ filterQuery = new RequestHeaderCQ();
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