Class CmsJSONSearchConfigurationParser
java.lang.Object
org.opencms.jsp.search.config.parser.CmsJSONSearchConfigurationParser
- All Implemented Interfaces:
I_CmsSearchConfigurationParser
- Direct Known Subclasses:
CmsSimpleSearchConfigurationParser
public class CmsJSONSearchConfigurationParser
extends Object
implements I_CmsSearchConfigurationParser
Search configuration parser reading JSON.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringThe JSON key for the default sort option, should hold the name paramvalue for the default option.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringThe JSON key for the sub-node with all field facet configurations.static final StringJSON keys for the Geo filter.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringThe JSON key for the subnode of all highlighting configuration.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringThe JSON key for the sub-node with the query facet configuration.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringThe JSON key for the sub-node with all field facet configurations.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringA JSON key.static final StringThe JSON key for the sub-node with all search option configurations.static final StringA JSON key.protected static final org.apache.commons.logging.LogLogger for the class.protected JSONObjectThe whole JSON file. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor taking the JSON as String.CmsJSONSearchConfigurationParser(String json, I_CmsSearchConfiguration baseConfig) Constructor taking the JSON as String.CmsJSONSearchConfigurationParser(JSONObject jsonObject) Constructor taking the JSON as JSONObject. -
Method Summary
Modifier and TypeMethodDescriptionReturns a map with additional request parameters, mapping the parameter names to Solr query parts.protected StringgetCore()Returns the configured Solr core, ornullif no core is configured.protected BooleanReturns the flag, indicating if the characters in the query string that are commands to Solr should be escaped.protected StringReturns the configured extra parameters that should be given to Solr, or the empty string if no parameters are configured.protected StringReturns the configured request parameter for the last query, or the default parameter if no core is configured.protected BooleanReturns a flag indicating if also expired resources should be found.protected BooleanReturns a flag indicating if the query given by the parameters should be ignored.protected BooleanReturns a flag indicating if also unreleased resources should be found.protected StringReturns the configured Solr index, ornullif no core is configured.protected StringReturns the configured request parameter for the last query, or the default parameter if no core is configured.protected intgetMaxReturnedResults(String indexName) Returns the number of maximally returned results, ornullif the indexes default should be used.protected IntegerReturns the configured length of the "Google"-like page navigation, or the default parameter if no core is configured.protected StringReturns the configured request parameter for the current page, or the default parameter if no core is configured.Returns the configured page sizes, or the default page size if no core is configured.protected StringReturns the optional query modifier.protected StringReturns the configured request parameter for the query string, or the default parameter if no core is configured.protected BooleanReturns a flag, indicating if search should be performed using a wildcard if the empty query is given.protected List<I_CmsSearchConfigurationSortOption> Returns the list of the configured sort options, or the empty list if no sort options are configured.protected StringReturns the configured request parameter for the sort option, or the default parameter if no core is configured.protected voidinit(String configString, I_CmsSearchConfiguration baseConfig) Initialization that parses the String to a JSON object.parseCommon(CmsObject cms) Returns the common search configuration.Returns the configuration for the "Did you mean ...?" feature.Parses a single query item for the query facet.parseFacetQueryItems(JSONObject queryFacetObject) Parses the list of query items for the query facet.protected I_CmsSearchConfigurationFacetFieldparseFieldFacet(JSONObject fieldFacetObject) Parses the field facet configurations.Returns the configuration for the field facets.Returns the configuration for the Geo filter.Returns the configuration for the highlighting.parseMandatoryStringValues(JSONObject json, String key) Helper for reading a mandatory String value list - throwing an Exception if parsing fails.protected static BooleanparseOptionalBooleanValue(JSONObject json, String key) Helper for reading an optional Boolean value - returningnullif parsing fails.protected static IntegerparseOptionalIntValue(JSONObject json, String key) Helper for reading an optional Integer value - returningnullif parsing fails.protected static StringparseOptionalStringValue(JSONObject json, String key) Helper for reading an optional String value - returningnullif parsing fails.parseOptionalStringValues(JSONObject json, String key) Helper for reading an optional String value list - returningnullif parsing fails for the whole list, otherwise just skipping unparsable entries.Returns the configuration for the pagination.Returns the configuration for the query facet.protected I_CmsSearchConfigurationFacetRangeparseRangeFacet(JSONObject rangeFacetObject) Parses the query facet configurations.Returns the configuration for the range facets.Returns the configuration for sorting.protected I_CmsSearchConfigurationSortOptionparseSortOption(JSONObject json) Returns a single sort option configuration as configured via the methods parameter, or null if the parameter does not specify a sort option.
-
Field Details
-
LOG
Logger for the class. -
JSON_KEY_QUERYPARAM
A JSON key.- See Also:
-
JSON_KEY_LAST_QUERYPARAM
A JSON key.- See Also:
-
JSON_KEY_ESCAPE_QUERY_CHARACTERS
A JSON key.- See Also:
-
JSON_KEY_RELOADED_PARAM
A JSON key.- See Also:
-
JSON_KEY_SEARCH_FOR_EMPTY_QUERY
A JSON key.- See Also:
-
JSON_KEY_IGNORE_QUERY
A JSON key.- See Also:
-
JSON_KEY_IGNORE_RELEASE_DATE
A JSON key.- See Also:
-
JSON_KEY_MAX_RETURNED_RESULTS
A JSON key.- See Also:
-
JSON_KEY_IGNORE_EXPIRATION_DATE
A JSON key.- See Also:
-
JSON_KEY_QUERY_MODIFIER
A JSON key.- See Also:
-
JSON_KEY_PAGEPARAM
A JSON key.- See Also:
-
JSON_KEY_INDEX
A JSON key.- See Also:
-
JSON_KEY_CORE
A JSON key.- See Also:
-
JSON_KEY_EXTRASOLRPARAMS
A JSON key.- See Also:
-
JSON_KEY_ADDITIONAL_PARAMETERS
A JSON key.- See Also:
-
JSON_KEY_ADDITIONAL_PARAMETERS_PARAM
A JSON key.- See Also:
-
JSON_KEY_ADDITIONAL_PARAMETERS_SOLRQUERY
A JSON key.- See Also:
-
JSON_KEY_PAGESIZE
A JSON key.- See Also:
-
JSON_KEY_PAGENAVLENGTH
A JSON key.- See Also:
-
JSON_KEY_FIELD_FACETS
The JSON key for the sub-node with all field facet configurations.- See Also:
-
JSON_KEY_RANGE_FACETS
The JSON key for the sub-node with all field facet configurations.- See Also:
-
JSON_KEY_QUERY_FACET
The JSON key for the sub-node with the query facet configuration.- See Also:
-
JSON_KEY_FACET_LIMIT
A JSON key.- See Also:
-
JSON_KEY_FACET_MINCOUNT
A JSON key.- See Also:
-
JSON_KEY_FACET_LABEL
A JSON key.- See Also:
-
JSON_KEY_FACET_FIELD
A JSON key.- See Also:
-
JSON_KEY_FACET_NAME
A JSON key.- See Also:
-
JSON_KEY_FACET_PREFIX
A JSON key.- See Also:
-
JSON_KEY_FACET_ORDER
A JSON key.- See Also:
-
JSON_KEY_FACET_FILTERQUERYMODIFIER
A JSON key.- See Also:
-
JSON_KEY_FACET_ISANDFACET
A JSON key.- See Also:
-
JSON_KEY_FACET_IGNOREALLFACETFILTERS
A JSON key.- See Also:
-
JSON_KEY_FACET_EXCLUDETAGS
A JSON key.- See Also:
-
JSON_KEY_FACET_PRESELECTION
A JSON key.- See Also:
-
JSON_KEY_RANGE_FACET_RANGE
A JSON key.- See Also:
-
JSON_KEY_RANGE_FACET_START
A JSON key.- See Also:
-
JSON_KEY_RANGE_FACET_END
A JSON key.- See Also:
-
JSON_KEY_RANGE_FACET_GAP
A JSON key.- See Also:
-
JSON_KEY_RANGE_FACET_OTHER
A JSON key.- See Also:
-
JSON_KEY_RANGE_FACET_HARDEND
A JSON key.- See Also:
-
JSON_KEY_RANGE_FACET_METHOD
A JSON key.- See Also:
-
JSON_KEY_QUERY_FACET_QUERY
A JSON key.- See Also:
-
JSON_KEY_QUERY_FACET_QUERY_QUERY
A JSON key.- See Also:
-
JSON_KEY_QUERY_FACET_QUERY_LABEL
A JSON key.- See Also:
-
JSON_KEY_SORTPARAM
A JSON key.- See Also:
-
JSON_KEY_DEFAULT_SORT_OPTION
The JSON key for the default sort option, should hold the name paramvalue for the default option.- See Also:
-
JSON_KEY_SORTOPTIONS
The JSON key for the sub-node with all search option configurations.- See Also:
-
JSON_KEY_SORTOPTION_LABEL
A JSON key.- See Also:
-
JSON_KEY_SORTOPTION_PARAMVALUE
A JSON key.- See Also:
-
JSON_KEY_SORTOPTION_SOLRVALUE
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER
The JSON key for the subnode of all highlighting configuration.- See Also:
-
JSON_KEY_HIGHLIGHTER_FIELD
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_SNIPPETS
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_FRAGSIZE
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_ALTERNATE_FIELD
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_MAX_LENGTH_ALTERNATE_FIELD
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_SIMPLE_PRE
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_SIMPLE_POST
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_FORMATTER
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_FRAGMENTER
A JSON key.- See Also:
-
JSON_KEY_HIGHLIGHTER_FASTVECTORHIGHLIGHTING
A JSON key.- See Also:
-
JSON_KEY_DIDYOUMEAN
A JSON key.- See Also:
-
JSON_KEY_DIDYOUMEAN_QUERYPARAM
A JSON key.- See Also:
-
JSON_KEY_DIDYOUMEAN_ESCAPE_QUERY
A JSON key.- See Also:
-
JSON_KEY_DIDYOUMEAN_COLLATE
A JSON key.- See Also:
-
JSON_KEY_DIDYOUMEAN_COUNT
A JSON key.- See Also:
-
JSON_KEY_GEO_FILTER
JSON keys for the Geo filter.- See Also:
-
JSON_KEY_GEO_FILTER_COORDINATES
A JSON key.- See Also:
-
JSON_KEY_GEO_FILTER_COORDINATES_PARAM
A JSON key.- See Also:
-
JSON_KEY_GEO_FILTER_FIELD_NAME
A JSON key.- See Also:
-
JSON_KEY_GEO_FILTER_RADIUS
A JSON key.- See Also:
-
JSON_KEY_GEO_FILTER_RADIUS_PARAM
A JSON key.- See Also:
-
JSON_KEY_GEO_FILTER_UNITS
A JSON key.- See Also:
-
JSON_KEY_GEO_FILTER_UNITS_PARAM
A JSON key.- See Also:
-
DEFAULT_QUERY_PARAM
A JSON key.- See Also:
-
DEFAULT_LAST_QUERY_PARAM
A JSON key.- See Also:
-
DEFAULT_RELOADED_PARAM
A JSON key.- See Also:
-
m_configObject
The whole JSON file.
-
-
Constructor Details
-
CmsJSONSearchConfigurationParser
Constructor taking the JSON as JSONObject.- Parameters:
jsonObject- The JSON that should be evaluated as JSONObject.
-
CmsJSONSearchConfigurationParser
Constructor taking the JSON as String.- Parameters:
json- The JSON that should be parsed as String.- Throws:
JSONException- Thrown if parsing fails.
-
CmsJSONSearchConfigurationParser
public CmsJSONSearchConfigurationParser(String json, I_CmsSearchConfiguration baseConfig) throws JSONException Constructor taking the JSON as String.- Parameters:
json- The JSON that should be parsed as String.baseConfig- A base configuration that is adjusted by the JSON configuration string.- Throws:
JSONException- Thrown if parsing fails.
-
-
Method Details
-
parseMandatoryStringValues
protected static List<String> parseMandatoryStringValues(JSONObject json, String key) throws JSONException Helper for reading a mandatory String value list - throwing an Exception if parsing fails.- Parameters:
json- The JSON object where the list should be read from.key- The key of the value to read.- Returns:
- The value from the JSON.
- Throws:
JSONException- thrown when parsing fails.
-
parseOptionalBooleanValue
Helper for reading an optional Boolean value - returningnullif parsing fails.- Parameters:
json- The JSON object where the value should be read from.key- The key of the value to read.- Returns:
- The value from the JSON, or
nullif the value does not exist, or is no Boolean.
-
parseOptionalIntValue
Helper for reading an optional Integer value - returningnullif parsing fails.- Parameters:
json- The JSON object where the value should be read from.key- The key of the value to read.- Returns:
- The value from the JSON, or
nullif the value does not exist, or is no Integer.
-
parseOptionalStringValue
Helper for reading an optional String value - returningnullif parsing fails.- Parameters:
json- The JSON object where the value should be read from.key- The key of the value to read.- Returns:
- The value from the JSON, or
nullif the value does not exist.
-
parseOptionalStringValues
Helper for reading an optional String value list - returningnullif parsing fails for the whole list, otherwise just skipping unparsable entries.- Parameters:
json- The JSON object where the list should be read from.key- The key of the value to read.- Returns:
- The value from the JSON, or
nullif the value does not exist.
-
parseCommon
Description copied from interface:I_CmsSearchConfigurationParserReturns the common search configuration.- Specified by:
parseCommonin interfaceI_CmsSearchConfigurationParser- Parameters:
cms- the current context- Returns:
- The common search configuration.
- See Also:
-
parseDidYouMean
Description copied from interface:I_CmsSearchConfigurationParserReturns the configuration for the "Did you mean ...?" feature.- Specified by:
parseDidYouMeanin interfaceI_CmsSearchConfigurationParser- Returns:
- The configuration for the "Did you mean ...?" feature.
- See Also:
-
parseFieldFacets
Description copied from interface:I_CmsSearchConfigurationParserReturns the configuration for the field facets.- Specified by:
parseFieldFacetsin interfaceI_CmsSearchConfigurationParser- Returns:
- The configuration for the field facets.
- See Also:
-
parseGeoFilter
Description copied from interface:I_CmsSearchConfigurationParserReturns the configuration for the Geo filter.- Specified by:
parseGeoFilterin interfaceI_CmsSearchConfigurationParser- Returns:
- The configuration for the Geo filter.
- See Also:
-
parseHighlighter
Description copied from interface:I_CmsSearchConfigurationParserReturns the configuration for the highlighting.- Specified by:
parseHighlighterin interfaceI_CmsSearchConfigurationParser- Returns:
- The configuration for the highlighting.
- See Also:
-
parsePagination
Description copied from interface:I_CmsSearchConfigurationParserReturns the configuration for the pagination.- Specified by:
parsePaginationin interfaceI_CmsSearchConfigurationParser- Returns:
- The configuration for the pagination.
- See Also:
-
parseQueryFacet
Description copied from interface:I_CmsSearchConfigurationParserReturns the configuration for the query facet.- Specified by:
parseQueryFacetin interfaceI_CmsSearchConfigurationParser- Returns:
- The configuration for the query facet.
- See Also:
-
parseRangeFacets
Description copied from interface:I_CmsSearchConfigurationParserReturns the configuration for the range facets.- Specified by:
parseRangeFacetsin interfaceI_CmsSearchConfigurationParser- Returns:
- The configuration for the range facets.
- See Also:
-
parseSorting
Description copied from interface:I_CmsSearchConfigurationParserReturns the configuration for sorting.- Specified by:
parseSortingin interfaceI_CmsSearchConfigurationParser- Returns:
- The configuration for sorting.
- See Also:
-
getAdditionalParameters
Returns a map with additional request parameters, mapping the parameter names to Solr query parts.- Returns:
- A map with additional request parameters, mapping the parameter names to Solr query parts.
-
getCore
Returns the configured Solr core, ornullif no core is configured.- Returns:
- The configured Solr core, or
nullif no core is configured.
-
getEscapeQueryChars
Returns the flag, indicating if the characters in the query string that are commands to Solr should be escaped.- Returns:
- the flag, indicating if the characters in the query string that are commands to Solr should be escaped.
-
getExtraSolrParams
Returns the configured extra parameters that should be given to Solr, or the empty string if no parameters are configured.- Returns:
- The configured extra parameters that should be given to Solr, or the empty string if no parameters are configured.
-
getFirstCallParam
Returns the configured request parameter for the last query, or the default parameter if no core is configured.- Returns:
- The configured request parameter for the last query, or the default parameter if no core is configured.
-
getIgnoreExpirationDate
Returns a flag indicating if also expired resources should be found.- Returns:
- A flag indicating if also expired resources should be found.
-
getIgnoreQuery
Returns a flag indicating if the query given by the parameters should be ignored.- Returns:
- A flag indicating if the query given by the parameters should be ignored.
-
getIgnoreReleaseDate
Returns a flag indicating if also unreleased resources should be found.- Returns:
- A flag indicating if also unreleased resources should be found.
-
getIndex
Returns the configured Solr index, ornullif no core is configured.- Parameters:
cms- the current context.- Returns:
- The configured Solr index, or
nullif no core is configured.
-
getLastQueryParam
Returns the configured request parameter for the last query, or the default parameter if no core is configured.- Returns:
- The configured request parameter for the last query, or the default parameter if no core is configured.
-
getMaxReturnedResults
Returns the number of maximally returned results, ornullif the indexes default should be used.- Parameters:
indexName- the name of the index to search in.- Returns:
- The number of maximally returned results, or
nullif the indexes default should be used.
-
getPageParam
Returns the configured request parameter for the current page, or the default parameter if no core is configured.- Returns:
- The configured request parameter for the current page, or the default parameter if no core is configured.
-
getPageSizes
Returns the configured page sizes, or the default page size if no core is configured.- Returns:
- The configured page sizes, or the default page size if no core is configured.
-
getQueryModifier
Returns the optional query modifier.- Returns:
- the optional query modifier.
-
getQueryParam
Returns the configured request parameter for the query string, or the default parameter if no core is configured.- Returns:
- The configured request parameter for the query string, or the default parameter if no core is configured.
-
getSearchForEmptyQuery
Returns a flag, indicating if search should be performed using a wildcard if the empty query is given.- Returns:
- A flag, indicating if search should be performed using a wildcard if the empty query is given.
-
getSortOptions
Returns the list of the configured sort options, or the empty list if no sort options are configured.- Returns:
- The list of the configured sort options, or the empty list if no sort options are configured.
-
getSortParam
Returns the configured request parameter for the sort option, or the default parameter if no core is configured.- Returns:
- The configured request parameter for the sort option, or the default parameter if no core is configured.
-
init
Initialization that parses the String to a JSON object.- Parameters:
configString- The JSON as string.baseConfig- The optional basic search configuration to overwrite (partly) by the JSON configuration.- Throws:
JSONException- thrown if parsing fails.
-
parseFacetQueryItem
protected I_CmsSearchConfigurationFacetQuery.I_CmsFacetQueryItem parseFacetQueryItem(JSONObject item) Parses a single query item for the query facet.- Parameters:
item- JSON object of the query item.- Returns:
- the parsed query item, or
nullif parsing failed.
-
parseFacetQueryItems
protected List<I_CmsSearchConfigurationFacetQuery.I_CmsFacetQueryItem> parseFacetQueryItems(JSONObject queryFacetObject) throws JSONException Parses the list of query items for the query facet.- Parameters:
queryFacetObject- JSON object representing the node with the query facet.- Returns:
- list of query options
- Throws:
JSONException- if the list cannot be parsed.
-
parseFieldFacet
Parses the field facet configurations.- Parameters:
fieldFacetObject- The JSON sub-node with the field facet configurations.- Returns:
- The field facet configurations.
-
parseRangeFacet
Parses the query facet configurations.- Parameters:
rangeFacetObject- The JSON sub-node with the query facet configurations.- Returns:
- The query facet configurations.
-
parseSortOption
Returns a single sort option configuration as configured via the methods parameter, or null if the parameter does not specify a sort option.- Parameters:
json- The JSON sort option configuration.- Returns:
- The sort option configuration, or null if the JSON could not be read.
-