Package de.cxp.ocs.util
Class ESQueryUtils
java.lang.Object
de.cxp.ocs.util.ESQueryUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getFuzzyTermLabel
(AssociatedTerm correctedWord) static String
getQueryLabel
(Collection<QueryStringTerm> termsUnique) static org.elasticsearch.index.query.BoolQueryBuilder
mapToBoolQueryBuilder
(org.elasticsearch.index.query.QueryBuilder query) If the inserted query is a BoolQueryBuilder, the queryBuilder is just returned.static org.elasticsearch.index.query.BoolQueryBuilder
mapToBoolQueryBuilder
(org.elasticsearch.index.query.QueryBuilder query, Function<org.elasticsearch.index.query.QueryBuilder, org.elasticsearch.index.query.BoolQueryBuilder> boolClauseFunction) If the inserted query is a BoolQueryBuilder, the queryBuilder is just returned.static org.elasticsearch.index.query.QueryBuilder
mergeQueries
(org.elasticsearch.index.query.QueryBuilder q1, org.elasticsearch.index.query.QueryBuilder q2) Make sure both queries are combined as a boolean query with must-clauses.static Optional
<SearchField> validateSearchField
(String fieldName, FieldConfigAccess fieldConfig) validateSearchFields
(Map<String, Float> weightedFields, FieldConfigAccess fieldConfig, Predicate<Field> additionalPredicate)
-
Constructor Details
-
ESQueryUtils
public ESQueryUtils()
-
-
Method Details
-
getQueryLabel
- Parameters:
termsUnique
- a list ofQueryStringTerm
s- Returns:
- a string that can be used to label a ES query
-
getFuzzyTermLabel
-
mapToBoolQueryBuilder
public static org.elasticsearch.index.query.BoolQueryBuilder mapToBoolQueryBuilder(org.elasticsearch.index.query.QueryBuilder query) If the inserted query is a BoolQueryBuilder, the queryBuilder is just returned. If not, it is wrapped in a Boolean Query with the query at the MUST clause.- Parameters:
query
- the query that should be wrapped into boolean query MUST-clause.- Returns:
- a boolean query
-
mapToBoolQueryBuilder
public static org.elasticsearch.index.query.BoolQueryBuilder mapToBoolQueryBuilder(org.elasticsearch.index.query.QueryBuilder query, Function<org.elasticsearch.index.query.QueryBuilder, org.elasticsearch.index.query.BoolQueryBuilder> boolClauseFunction) If the inserted query is a BoolQueryBuilder, the queryBuilder is just returned. If not, the provided function is called to wrap the query into a BoolQueryBuilder.- Parameters:
query
- the query that should be wrapped into boolean queryboolClauseFunction
- the wrapper function that is called in case the query is not a boolean-query.- Returns:
- a boolean query
-
mergeQueries
public static org.elasticsearch.index.query.QueryBuilder mergeQueries(org.elasticsearch.index.query.QueryBuilder q1, org.elasticsearch.index.query.QueryBuilder q2) Make sure both queries are combined as a boolean query with must-clauses. If one of them already is a boolean query with must clauses, the other one will be appended to it.- Parameters:
q1
- first queryq2
- second query- Returns:
- q1 or q2 if one of them is null, otherwise a
BoolQueryBuilder
-
validateSearchFields
-
validateSearchField
public static Optional<SearchField> validateSearchField(String fieldName, FieldConfigAccess fieldConfig)
-