Class SearchHelper

java.lang.Object
io.goobi.viewer.model.search.SearchHelper

public final class SearchHelper extends Object
Search utility class. Static methods only.
  • Field Details

    • PARAM_NAME_FILTER_QUERY_SUFFIX

      public static final String PARAM_NAME_FILTER_QUERY_SUFFIX
      Constant PARAM_NAME_FILTER_QUERY_SUFFIX="filterQuerySuffix"
      See Also:
    • SEARCH_TERM_SPLIT_REGEX

      public static final String SEARCH_TERM_SPLIT_REGEX
      Constant SEARCH_TERM_SPLIT_REGEX
      See Also:
    • PLACEHOLDER_HIGHLIGHTING_START

      public static final String PLACEHOLDER_HIGHLIGHTING_START
      Constant PLACEHOLDER_HIGHLIGHTING_START="##HLS##"
      See Also:
    • PLACEHOLDER_HIGHLIGHTING_END

      public static final String PLACEHOLDER_HIGHLIGHTING_END
      Constant PLACEHOLDER_HIGHLIGHTING_END="##HLE##"
      See Also:
    • SEARCH_TYPE_REGULAR

      public static final int SEARCH_TYPE_REGULAR
      Constant SEARCH_TYPE_REGULAR=0
      See Also:
    • SEARCH_TYPE_ADVANCED

      public static final int SEARCH_TYPE_ADVANCED
      Constant SEARCH_TYPE_ADVANCED=1
      See Also:
    • SEARCH_TYPE_TIMELINE

      public static final int SEARCH_TYPE_TIMELINE
      Constant SEARCH_TYPE_TIMELINE=2
      See Also:
    • SEARCH_TYPE_CALENDAR

      public static final int SEARCH_TYPE_CALENDAR
      Constant SEARCH_TYPE_CALENDAR=3
      See Also:
    • SEARCH_TYPE_TERMS

      public static final int SEARCH_TYPE_TERMS
      Constant SEARCH_TYPE_TERMS=4
      See Also:
    • SEARCH_FILTER_ALL

      public static final SearchFilter SEARCH_FILTER_ALL
      Constant SEARCH_FILTER_ALL
    • SEARCH_FILTER_ALL_FIELD

      public static final String SEARCH_FILTER_ALL_FIELD
      See Also:
    • TITLE_TERMS

      public static final String TITLE_TERMS
      See Also:
    • AGGREGATION_QUERY_PREFIX

      public static final String AGGREGATION_QUERY_PREFIX
      See Also:
    • BOOSTING_QUERY_TEMPLATE

      public static final String BOOSTING_QUERY_TEMPLATE
      See Also:
    • EMBEDDED_QUERY_TEMPLATE

      public static final String EMBEDDED_QUERY_TEMPLATE
      See Also:
    • ALL_RECORDS_QUERY

      public static final String ALL_RECORDS_QUERY
      Standard Solr query for all records and anchors.
      See Also:
    • DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY

      public static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY
      Constant DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY="(ISWORK:true OR ISANCHOR:true) AND NOT("{trunked}
      See Also:
    • FUZZY_SEARCH_TERM_TEMPLATE_WITH_BOOST

      public static final String FUZZY_SEARCH_TERM_TEMPLATE_WITH_BOOST
      Constant FUZZY_SEARCH_TERM_TEMPLATE_WITH_BOOST="String prefix, String suffix". {t} is the actual search term, {d} the maximal edit distance to search. {p} and {s} are prefix and suffix to be applied to the search term
      See Also:
    • FUZZY_SEARCH_TERM_TEMPLATE

      public static final String FUZZY_SEARCH_TERM_TEMPLATE
      Constant FUZZY_SEARCH_TERM_TEMPLATE="String prefix, String suffix". {t} is the actual search term, {d} the maximal edit distance to search.
      See Also:
    • PATTERN_ALL_ITEMS

      public static final Pattern PATTERN_ALL_ITEMS
  • Method Details

    • searchWithFulltext

      public static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields, List<String> filterQueries, Map<String,String> params, Map<String,Set<String>> searchTerms, List<String> exportFields, Locale locale, int proximitySearchDistance) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException
      Main search method for flat search.
      Parameters:
      query - String Solr search query. Merges full-text and metadata hits into their corresponding docstructs.
      first - Integer First row index
      rows - Integer Number of rows to return
      sortFields - a List object.
      resultFields - a List object.
      filterQueries - a List object.
      params - a Map object.
      searchTerms - a Map object.
      exportFields - a List object.
      locale - a Locale object.
      proximitySearchDistance -
      Returns:
      List of StructElements containing the search hits.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • searchWithFulltext

      public static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields, List<String> filterQueries, Map<String,String> params, Map<String,Set<String>> searchTerms, List<String> exportFields, Locale locale, boolean keepSolrDoc, int proximitySearchDistance) throws PresentationException, IndexUnreachableException, DAOException
      Main search method for flat search.
      Parameters:
      query - String Solr search query. Merges full-text and metadata hits into their corresponding docstructs.
      first - Integer von
      rows - Integer bis
      sortFields - a List object.
      resultFields - a List object.
      filterQueries - a List object.
      params - a Map object.
      searchTerms - a Map object.
      exportFields - a List object.
      locale - a Locale object.
      keepSolrDoc -
      proximitySearchDistance -
      Returns:
      List of StructElements containing the search hits.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
    • searchWithAggregation

      public static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields, List<String> filterQueries, Map<String,String> params, Map<String,Set<String>> searchTerms, List<String> exportFields, String additionalMetadataListType, Locale locale, boolean keepSolrDoc, int proximitySearchDistance) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException
      Main search method for aggregated search.
      Parameters:
      query - String Solr search query. Merges full-text and metadata hits into their corresponding docstructs.
      first - Integer First hit index
      rows - Integer Number of hits to return
      sortFields - a List object.
      resultFields - a List object.
      filterQueries - a List object.
      params - a Map object.
      searchTerms - a Map object.
      exportFields - a List object.
      additionalMetadataListType - Optional addtional metadata list type, to be used on alternative search hit views, etc.
      locale - a Locale object.
      keepSolrDoc -
      proximitySearchDistance -
      Returns:
      List of StructElements containing the search hits.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getHitType

      public static HitType getHitType(org.apache.solr.common.SolrDocument doc)
      Return the HitType matching the SolrConstants.DOCTYPE of the given document. In case the document is of type 'UGC', return the type matching SolrConstants.UGCTYPE instead
      Parameters:
      doc -
      Returns:
      HitType for doc
    • getAllSuffixes

      public static String getAllSuffixes()
      Returns all suffixes relevant to search filtering.
      Returns:
      a String object.
    • getAllSuffixes

      public static String getAllSuffixes(javax.servlet.http.HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix)
      Returns all suffixes relevant to search filtering.
      Parameters:
      request - a HttpServletRequest object.
      addStaticQuerySuffix - a boolean.
      addCollectionBlacklistSuffix - a boolean.
      Returns:
      Generated Solr query suffix
    • getAllSuffixes

      public static String getAllSuffixes(javax.servlet.http.HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix, String privilege)
      Parameters:
      request - a HttpServletRequest object.
      addStaticQuerySuffix - a boolean.
      addCollectionBlacklistSuffix - a boolean.
      privilege - Privilege to check (Connector checks a different privilege)
      Returns:
      Generated Solr query suffix
    • getAllSuffixes

      public static String getAllSuffixes(javax.servlet.http.HttpServletRequest request, boolean addArchiveFilterSuffix, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix, String privilege)
      Returns all suffixes relevant to search filtering.
      Parameters:
      request - a HttpServletRequest object.
      addArchiveFilterSuffix - a boolean.
      addCollectionBlacklistSuffix - a boolean.
      privilege - Privilege to check (Connector checks a different privilege)
      addStaticQuerySuffix - if true, add the configured static query suffix to the query
      Returns:
      Generated Solr query suffix
    • getAllSuffixesExceptCollectionBlacklist

      public static String getAllSuffixesExceptCollectionBlacklist()
      Returns all suffixes relevant to search filtering.
      Returns:
      a String object.
    • getBrowseElement

      public static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries, Map<String,String> params, Map<String,Set<String>> searchTerms, Locale locale, int proximitySearchDistance) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException
      Returns the BrowseElement constructed from the search hit at index from the search hit list for the given query.
      Parameters:
      query - a String object.
      index - a int.
      sortFields - a List object.
      params - a Map object.
      searchTerms - a Map object.
      locale - a Locale object.
      proximitySearchDistance -
      filterQueries - a List object.
      Returns:
      a BrowseElement object.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getFirstRecordPiAndPageType

      public static StringPair getFirstRecordPiAndPageType(String luceneField, String value, boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar) throws IndexUnreachableException, PresentationException

      getFirstRecordMetadataWithFieldValue.

      Parameters:
      luceneField - a String object.
      value - a String object.
      filterForWhitelist - a boolean.
      filterForBlacklist - a boolean.
      splittingChar - a String object.
      Returns:
      StringPair containing the PI and the target page type of the first record.
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
    • findAllCollectionsFromField

      public static Map<String,CollectionResult> findAllCollectionsFromField(String luceneField, String groupingField, String filterQuery, boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar) throws IndexUnreachableException
      Returns a Map with hierarchical values from the given field and their respective record counts. Results are filtered by AccessConditions available for current HttpRequest
      Parameters:
      luceneField - the SOLR field over which to build the collections (typically "DC")
      groupingField -
      filterQuery - An addition solr-query to filer collections by.
      filterForWhitelist - a boolean.
      filterForBlacklist - a boolean.
      splittingChar - Character used for separating collection hierarchy levels within a collection name (typically ".")
      Returns:
      a Map object.
      Throws:
      IndexUnreachableException - if any.
    • checkCollectionInBlacklist

      protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar)
      Matches given collection name against the given collection blacklist. Also matches wildcards and child collections.
      Parameters:
      dc - a String object.
      blacklist - a Set object.
      splittingChar - a String object.
      Returns:
      a boolean.
    • searchCalendar

      public static org.apache.solr.client.solrj.response.QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics) throws PresentationException, IndexUnreachableException

      searchCalendar.

      Parameters:
      query - a String object.
      facetFields - a List object.
      facetMinCount - a int.
      getFieldStatistics - a boolean.
      Returns:
      a QueryResponse object.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getMinMaxYears

      public static int[] getMinMaxYears(String subQuery) throws PresentationException, IndexUnreachableException

      getMinMaxYears.

      Parameters:
      subQuery - a String object.
      Returns:
      int[]
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • searchAutosuggestion

      public static List<String> searchAutosuggestion(String suggest, List<IFacetItem> currentFacets) throws IndexUnreachableException
      search method for auto suggestion
    • First search in field "DEFAULT" and analyze values tokenized, check with startsWith
    • Then search in field "TITLE" and check with contains
    • Parameters:
      suggest - the search string
      currentFacets - a List object.
      Returns:
      a List object.
      Throws:
      IndexUnreachableException - if any.
    • getCollectionBlacklistFilterSuffix

      public static String getCollectionBlacklistFilterSuffix(String field)
      Returns a Solr query suffix that filters out collections defined in the collection blacklist.
      Parameters:
      field - a String object.
      Returns:
      a String object.
    • generateCollectionBlacklistFilterSuffix

      protected static String generateCollectionBlacklistFilterSuffix(String field)
      Generates a Solr query suffix that filters out values for the given field that are configured as blacklisted. This isn't an expensive method, so the suffix is generated anew upon every call and not persisted.
      Parameters:
      field - a String object.
      Returns:
      a String object.
    • getDiscriminatorFieldFilterSuffix

      public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException

      getDiscriminatorFieldFilterSuffix.

      Parameters:
      discriminatorField - a String object.
      nh - a NavigationHelper object.
      Returns:
      a String object.
      Throws:
      IndexUnreachableException - if any.
    • updateFilterQuerySuffix

      public static void updateFilterQuerySuffix(javax.servlet.http.HttpServletRequest request, String privilege) throws IndexUnreachableException, PresentationException, DAOException
      Updates the calling agent's session with a personalized filter sub-query.
      Parameters:
      request - a HttpServletRequest object.
      privilege - Privilege to check (Connector checks a different privilege)
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
    • getPersonalFilterQuerySuffix

      public static String getPersonalFilterQuerySuffix(List<LicenseType> licenseTypes, User user, String ipAddress, Optional<ClientApplication> client, String privilege) throws IndexUnreachableException, PresentationException, DAOException
      Constructs a personal search query filter suffix for the given user and IP address.
      Parameters:
      licenseTypes -
      user - a User object.
      ipAddress - a String object.
      client -
      privilege - Privilege to check (Connector checks a different privilege)
      Returns:
      a String object.
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
    • getMovingWallQuery

      public static String getMovingWallQuery()
      Returns:
      Solr query for the moving wall date range
    • truncateFulltext

      public static List<String> truncateFulltext(Set<String> searchTerms, String inFulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches, int proximitySearchDistance)
      TODO This method might be quite expensive.
      Parameters:
      searchTerms - a Set object.
      inFulltext - a String object.
      targetFragmentLength - Desired (approximate) length of the text fragment.
      firstMatchOnly - If true, only the fragment for the first match will be returned
      addFragmentIfNoMatches - If true, a fragment will be added even if no term was matched
      proximitySearchDistance -
      Returns:
      a List object.
    • applyHighlightingToPhrase

      public static String applyHighlightingToPhrase(String phrase, Set<String> terms)
      Adds highlighting markup for all given terms to the phrase.
      Parameters:
      phrase - a String object.
      terms - a Set object.
      Returns:
      a String object.
    • contains

      public static boolean contains(String phrase, String term, int maxDistance)
      if maxDistance <= 0, or either phrase or term is blank, simply return StringUtils.contains(phrase, term). Otherwise check if the phrase contains a word which has a Damerau-Levenshtein distance of at most maxDistance to the term
      Parameters:
      phrase -
      term -
      maxDistance -
      Returns:
      true if phrase contains term within maxDistance; false otherwise
    • replaceHighlightingPlaceholders

      public static String replaceHighlightingPlaceholders(String phrase)

      replaceHighlightingPlaceholders.

      Parameters:
      phrase - a String object.
      Returns:
      a String object.
    • removeHighlightingPlaceholders

      public static String removeHighlightingPlaceholders(String phrase)
      Parameters:
      phrase -
      Returns:
      phrase without highlighting placeholders
    • getFacetValues

      public static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount) throws PresentationException, IndexUnreachableException
      Returns a list of values for a given facet field and the given query.
      Parameters:
      query - a String object.
      facetFieldName - a String object.
      facetMinCount - a int.
      Returns:
      a List object.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getFacetValues

      public static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount, Map<String,String> params) throws PresentationException, IndexUnreachableException
      Returns a list of values for a given facet field and the given query.
      Parameters:
      query - a String object.
      facetFieldName - a String object.
      facetPrefix - The facet field value must start with these characters. Ignored if null or blank
      facetMinCount - a int.
      params -
      Returns:
      a List object.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getFilteredTermsCount

      public static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, String language) throws PresentationException, IndexUnreachableException
      Parameters:
      bmfc -
      startsWith -
      filterQuery -
      language -
      Returns:
      Number of found terms
      Throws:
      PresentationException
      IndexUnreachableException
    • collectAvailableTermFilters

      public static List<String> collectAvailableTermFilters(BrowsingMenuFieldConfig bmfc, String filterQuery, Locale locale) throws PresentationException, IndexUnreachableException
      Generates starting character filters for term browsing, using facets.
      Parameters:
      bmfc -
      filterQuery -
      locale -
      Returns:
      List
      Throws:
      PresentationException
      IndexUnreachableException
    • getFilteredTerms

      public static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows, Comparator<BrowseTerm> comparator, String language) throws PresentationException, IndexUnreachableException
      Returns a list of index terms for the given field name. This method uses the slower doc search instead of term search, but can be filtered with a query.
      Parameters:
      bmfc - a BrowsingMenuFieldConfig object.
      startsWith - a String object.
      filterQuery - a String object.
      start -
      rows -
      comparator - a Comparator object.
      language - Language for language-specific fields
      Returns:
      a List object.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • extractSearchTermsFromQuery

      public static Map<String,Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue)
      Parses the given Solr query for field values and returns them as a set of strings.
      Parameters:
      query - a String object.
      discriminatorValue - a String object.
      Returns:
      a Map object.
    • parseSearchQueryGroupFromQuery

      public static SearchQueryGroup parseSearchQueryGroupFromQuery(String query, String facetString, String template, String language)
      Parameters:
      query -
      facetString -
      template - Advanced search fields template
      language -
      Returns:
      Parsed SearchQueryGroup
    • removeTruncation

      public static String removeTruncation(String value)
      Remove '*' at the start or end of the given value
      Parameters:
      value -
      Returns:
      value without truncation
    • generateQueryParams

      public static Map<String,String> generateQueryParams(String termQuery)

      generateQueryParams.

      Parameters:
      termQuery -
      Returns:
      a Map object.
    • facetifyList

      public static List<String> facetifyList(List<String> sourceList)

      facetifyList.

      Parameters:
      sourceList - a List object.
      Returns:
      a List object. * @should facetify correctly
    • facetifyField

      public static String facetifyField(String fieldName)

      facetifyField.

      Parameters:
      fieldName - a String object.
      Returns:
      a String object.
    • sortifyField

      public static String sortifyField(String fieldName)

      sortifyField.

      Parameters:
      fieldName - a String object.
      Returns:
      a String object.
    • boolifyField

      public static String boolifyField(String fieldName)

      boolifyField.

      Parameters:
      fieldName - a String object.
      Returns:
      a String object.
    • normalizeField

      public static String normalizeField(String fieldName)
      Parameters:
      fieldName -
      Returns:
      Normalized fieldName
    • defacetifyField

      public static String defacetifyField(String fieldName)

      defacetifyField.

      Parameters:
      fieldName - a String object.
      Returns:
      a String object.
    • generateExpandQuery

      public static String generateExpandQuery(List<String> fields, Map<String,Set<String>> searchTerms, boolean phraseSearch, int proximitySearchDistance)
      Creates a Solr expand query string out of lists of fields and terms.
      Parameters:
      fields - a List object.
      searchTerms - a Map object.
      phraseSearch - If true, quotation marks are added to terms
      proximitySearchDistance -
      Returns:
      a String object.
    • generateAdvancedExpandQuery

      public static String generateAdvancedExpandQuery(SearchQueryGroup group, boolean allowFuzzySearch)
      Creates a Solr expand query string out of advanced search query item groups.
      Parameters:
      group -
      allowFuzzySearch -
      Returns:
      a String object.
    • getExpandQueryFieldList

      public static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, SearchQueryGroup queryGroup, List<String> additionalFields)

      getExpandQueryFieldList.

      Parameters:
      searchType - a int.
      searchFilter - a SearchFilter object.
      queryGroup - a SearchQueryGroup object.
      additionalFields - Optinal additional fields to return
      Returns:
      a List object.
    • prepareQuery

      public static String prepareQuery(String query)

      prepareQuery.

      Parameters:
      query - a String object.
      Returns:
      a String object.
    • prepareQuery

      public static String prepareQuery(String query, String docstructWhitelistFilterQuery)
      Puts non-empty queries into parentheses and replaces empty queries with a top level record-only query (for collection listing).
      Parameters:
      query - a String object.
      docstructWhitelistFilterQuery - a String object.
      Returns:
      a String object.
    • buildTermQuery

      public static String buildTermQuery(Collection<String> searchTerms)
      Parameters:
      searchTerms -
      Returns:
      Term query from searchTerms
    • buildTermQuery

      public static String buildTermQuery(Collection<String> searchTerms, boolean addOperators)
      Parameters:
      searchTerms -
      addOperators -
      Returns:
      Term query from searchTerms
    • buildFinalQuery

      public static String buildFinalQuery(String rawQuery, boolean boostTopLevelDocstructs, SearchAggregationType aggregationType)
      Constructs the complete query using the raw query and adding all available suffixes.
      Parameters:
      rawQuery - a String object.
      boostTopLevelDocstructs - If true, query elements for boosting will be added
      aggregationType - SearchAggregationType
      Returns:
      a String object.
      Throws:
      IndexUnreachableException - if any.
    • buildFinalQuery

      public static String buildFinalQuery(String rawQuery, boolean boostTopLevelDocstructs, javax.servlet.http.HttpServletRequest request, SearchAggregationType aggregationType)
      Constructs the complete query using the raw query and adding all available suffixes.
      Parameters:
      rawQuery - a String object.
      boostTopLevelDocstructs - If true, query elements for boosting will be added
      request -
      aggregationType - SearchAggregationType
      Returns:
      a String object.
    • exportSearchAsExcel

      public static void exportSearchAsExcel(org.apache.poi.xssf.streaming.SXSSFWorkbook wb, String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries, Map<String,String> params, Map<String,Set<String>> searchTerms, Locale locale, int proximitySearchDistance) throws IndexUnreachableException, DAOException, PresentationException, ViewerConfigurationException

      exportSearchAsExcel.

      Parameters:
      wb - SXSSFWorkbook to populate
      finalQuery - Complete query with suffixes.
      exportQuery - Query constructed from the user's input, without any secret suffixes.
      sortFields - a List object.
      filterQueries - a List object.
      params - a Map object.
      searchTerms - a Map object.
      locale - a Locale object.
      proximitySearchDistance -
      Throws:
      IndexUnreachableException - if any.
      DAOException - if any.
      PresentationException - if any.
      ViewerConfigurationException - if any.
    • parseSortString

      public static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper)

      parseSortString.

      Parameters:
      sortString - a String object.
      navigationHelper - a NavigationHelper object.
      Returns:
      a List object.
    • getExpandQueryParams

      public static Map<String,String> getExpandQueryParams(String expandQuery)
      Parameters:
      expandQuery -
      Returns:
      Map<String, String>
    • cleanUpSearchTerm

      public static String cleanUpSearchTerm(String term)
      Removes illegal characters from an individual search term. Do not use on whole queries!
      Parameters:
      term - The term to clean up.
      Returns:
      Cleaned up term.
    • getQueryForAccessCondition

      public static String getQueryForAccessCondition(String accessCondition, boolean escapeAccessCondition)
      Parameters:
      accessCondition -
      escapeAccessCondition -
      Returns:
      Constructed Solr query
    • addFuzzySearchToken

      public static String addFuzzySearchToken(String term, String prefix, String suffix)
      Adds a fuzzy search token to the given term. The maximal Damerau-Levenshtein is calculated from term length
      Parameters:
      term - the search term
      prefix -
      suffix -
      Returns:
      the given term with a fuzzy search token appended
    • addFuzzySearchToken

      public static String addFuzzySearchToken(String term, int distance, String prefix, String suffix)
      Parameters:
      term - the search term. Must be a single word
      distance - the maximum Damerau-Levenshtein distance to a matching word. Must be from 0 to 2, where 0 means no fuzzy search
      prefix -
      suffix -
      Returns:
      term with fuzzy search token
    • addProximitySearchToken

      public static String addProximitySearchToken(String term, int distance)
      Parameters:
      term -
      distance -
      Returns:
      String
    • removeProximitySearchToken

      public static String removeProximitySearchToken(String term)
      Parameters:
      term - Search term containing proximity search token
      Returns:
      term without proximity search token
    • extractProximitySearchDistanceFromQuery

      public static int extractProximitySearchDistanceFromQuery(String query)
      Parameters:
      query -
      Returns:
      Extracted search distance
    • isPhrase

      public static boolean isPhrase(String s)
      Determines whether the given string is a quoted search phrase, optionally with a proximity distance.
      Parameters:
      s - Search terms
      Returns:
      true if phrase; false otherwise
    • getWildcardsTokens

      public static String[] getWildcardsTokens(String term)
      Separate leading and trailing wildcard token ('*') from the actual term and return an array of length 3 with the values [leadingWildCard, tokenWithoutWildcards, trailingWildcard] If leading/trailing wildcards are missing, the corresponding array entries are empty strings
      Parameters:
      term -
      Returns:
      array of prefix, token, suffix
    • buildExpandQueryFromFacets

      public static String buildExpandQueryFromFacets(List<String> allFacetQueries, List<String> allowedFacetQueryRegexes)
      Constructs an expand query from given facet queries. Constrains the query to DOCSTRCT doc types only.
      Parameters:
      allFacetQueries -
      allowedFacetQueryRegexes - Optional list containing regexes for allowed facet queries
      Returns:
      Expand query