Class ESQueryUtils

java.lang.Object
de.cxp.ocs.util.ESQueryUtils

public class ESQueryUtils extends Object
  • Constructor Details

    • ESQueryUtils

      public ESQueryUtils()
  • Method Details

    • getQueryLabel

      public static String getQueryLabel(Collection<QueryStringTerm> termsUnique)
      Parameters:
      termsUnique - a list of QueryStringTerms
      Returns:
      a string that can be used to label a ES query
    • getFuzzyTermLabel

      public static String getFuzzyTermLabel(AssociatedTerm correctedWord)
    • 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 query
      boolClauseFunction - 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 query
      q2 - second query
      Returns:
      q1 or q2 if one of them is null, otherwise a BoolQueryBuilder
    • validateSearchFields

      public static Map<String,Float> validateSearchFields(Map<String,Float> weightedFields, FieldConfigAccess fieldConfig, Predicate<Field> additionalPredicate)
    • validateSearchField

      public static Optional<SearchField> validateSearchField(String fieldName, FieldConfigAccess fieldConfig)