Class SearchQueryUtils
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils
-
public class SearchQueryUtils extends Object
Some static methods to help in constructing search queries and parsing the results.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSearchQueryUtils.Conjunction
-
Constructor Summary
Constructors Constructor Description SearchQueryUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringassembleConjunctiveQuery(String fieldName, Collection<String> words, SearchQueryUtils.Conjunction c)Glue these words together into a query on a given field, joined by either AND or OR.static FieldMapfieldMap()Create a builder object that can assemble a map of search result field names to JSON field names.static StringgetAlphaParameter(VitroRequest request)Methods that can be used in multiple places, such as IndividualListController and SearchIndividualsDataGetterstatic longgetIndividualCount(List<String> vclassUris)static StringgetLabelFieldNameForLocale(Locale locale)static intgetPageParameter(VitroRequest request)static SearchQuerygetQuery(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.static SearchQuerygetRandomQuery(List<String> vclassUris, int page, int pageSize)static StringgetSortFieldNameForLocale(Locale locale)static StringmakeMultiClassQuery(List<String> vclassUris)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.static AutoCompleteWordsparseForAutoComplete(String searchTerm, String delimiterPattern)Create an AutoCompleteWords object that can be used to build an auto-complete query.static List<Map<String,String>>parseResponse(SearchResponse queryResponse, FieldMap fieldMap)Parse a response into a list of maps, one map for each document.static List<String>parseWords(String typesString, String wordDelimiter)Break a string into a list of words, according to a RegEx delimiter.
-
-
-
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.
-
assembleConjunctiveQuery
public static String assembleConjunctiveQuery(String fieldName, Collection<String> words, SearchQueryUtils.Conjunction c)
Glue these words together into a query on a given field, joined by either AND or OR.
-
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)
-
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.
-
getRandomQuery
public static SearchQuery getRandomQuery(List<String> vclassUris, int page, int pageSize)
-
-