Class SearchQueryUtils


  • public class SearchQueryUtils
    extends Object
    Some static methods to help in constructing search queries and parsing the results.
    • Constructor Detail

      • SearchQueryUtils

        public SearchQueryUtils()
    • Method Detail

      • parseForAutoComplete

        public static AutoCompleteWords parseForAutoComplete​(String searchTerm,
                                                             String delimiterPattern)
        Create an AutoCompleteWords object that can be used to build an auto-complete query.
      • fieldMap

        public static FieldMap fieldMap()
        Create a builder object that can assemble a map of search result field names to JSON field names.
      • parseResponse

        public static List<Map<String,​String>> parseResponse​(SearchResponse queryResponse,
                                                                   FieldMap fieldMap)
        Parse a response into a list of maps, one map for each document. The search result field names in the document are replaced by json field names in the result, according to the fieldMap.
      • parseAndFilterResponse

        public static List<Map<String,​String>> parseAndFilterResponse​(SearchResponse queryResponse,
                                                                            FieldMap fieldMap,
                                                                            SearchResponseFilter filter,
                                                                            int maxNumberOfResults)
        Parse a response into a list of maps, accepting only those maps that pass a filter, and only up to a maximum number of records. The search result field names in the document are replaced by json field names in the result, according to the fieldMap.
      • parseWords

        public static List<String> parseWords​(String typesString,
                                              String wordDelimiter)
        Break a string into a list of words, according to a RegEx delimiter. Trim leading and trailing white space from each word.
      • getAlphaParameter

        public static String getAlphaParameter​(VitroRequest request)
        Methods that can be used in multiple places, such as IndividualListController and SearchIndividualsDataGetter
      • getPageParameter

        public static int getPageParameter​(VitroRequest request)
      • getIndividualCount

        public static long getIndividualCount​(List<String> vclassUris)
      • getQuery

        public static SearchQuery getQuery​(List<String> vclassUris,
                                           String alpha,
                                           Locale locale,
                                           int page,
                                           int pageSize)
        builds a query with a type clause for each type in vclassUris, NAME_LOWERCASE filtered by alpha, and just the hits for the page for pageSize.
        Parameters:
        locale - may be null. If null, default sort field will be used. Otherwise, query will be sorted by locale-specific sort field.
      • getSortFieldNameForLocale

        public static String getSortFieldNameForLocale​(Locale locale)
      • getLabelFieldNameForLocale

        public static String getLabelFieldNameForLocale​(Locale locale)
      • getRandomQuery

        public static SearchQuery getRandomQuery​(List<String> vclassUris,
                                                 int page,
                                                 int pageSize)
      • makeMultiClassQuery

        public static String makeMultiClassQuery​(List<String> vclassUris)