Class SearchQuestion


  • public class SearchQuestion
    extends Object

    This class contains all the input data related to a search.

    This data will be collected from the input parameters (query string parameters) and possibly transformed by some processing before PADRE is called.

    Since:
    11.0
    • Field Detail

      • executionContext

        private ExecutionContext executionContext
        Execution context of the Search UI. Can be "admin" or "public", depending if the search is ran on the admin port or public port.
        Since:
        15.12
      • requestHeaders

        private com.google.common.collect.ListMultimap<String,​String> requestHeaders
        Headers provided with the incoming search request
        Since:
        15.16
      • query

        private String query

        Query terms.

        This may be transformed before being passed to PADRE, depending on the configuration.

      • originalQuery

        private String originalQuery
        Original query, as entered by the user.
      • profile

        @NonNull
        private @NonNull String profile
        The profile to search with, defaulting to "_default".
      • currentProfile

        private String currentProfile
        The profile which will be used for the request. This one will always correspond to the name of a profile which exists within the selected collection. Note that this may differ from profile if the requested profile does not actually exist on disk (in which case it will be set to DefaultValues.DEFAULT_PROFILE, as that is what's used).
        Since:
        15.12
      • clive

        private String[] clive
        Specific component of a meta-collection to query
      • form

        @NonNull
        private @NonNull String form
        Display form (template)
      • cnClickedCluster

        private String cnClickedCluster
        Contextual Navigation: last clicked cluster
      • cnPreviousClusters

        private final List<String> cnPreviousClusters
        Contextual Navigation: Previous clicked clusters
      • metaParameters

        private final List<String> metaParameters

        meta_* / query_* input parameters, transformed in query expressions.

        Those parameters are supposed to be specified by the user, usually in an advanced search form. If you need to inject parameters for technical / behind-the-scene reasons, consider using systemMetaParameters.

        See Also:
        systemMetaParameters
      • systemMetaParameters

        private final List<String> systemMetaParameters

        smeta_* / squery_* input parameters, transformed in query expressions.

        Those parameters are supposed to be "technical" parameters, usually injected through a hook script. If you want the user to specify parameters, consider using metaParameters.

        Since:
        12.2
        See Also:
        metaParameters
      • additionalParameters

        private final Map<String,​String[]> additionalParameters

        Additional parameters to pass as-is to PADRE.

        The values of this map will be passed through to PADRE and won't be processed at all by the Modern UI. Only parameters relevant to PADRE should be injected here.

        Depending on the parameters you want to inject or manipulate, consider using inputParameters. Those parameters will be processed by the Modern UI (For example to inject faceted navigation constraints).

        Note that this map is populated before the first hook script is run: Any additional parameter injected in inputParameters in a hook script won't be copied to this map.

      • environmentVariables

        private final Map<String,​String> environmentVariables
        List of environment variables to pass to PADRE.
      • dynamicQueryProcessorOptions

        private final List<String> dynamicQueryProcessorOptions

        Dynamic query processor options for PADRE, in addition to the one set in collection.cfg.

        Will be updated by the input processing.

      • priorityQueryProcessorOptions

        private final PriorityQueryProcessorOptions priorityQueryProcessorOptions
        Query processor options that are guaranteed to apply.

        Internal use only

        Since:
        15.12
      • userKeys

        private final List<String> userKeys

        User keys for early binding Document Level Security.

      • selectedFacets

        private final Set<String> selectedFacets

        List of selected facets.

        Contains the name of the facets that were selected, such as "Location" or "Brand", but not the actual value.

      • selectedCategoryValues

        private final Map<String,​List<String>> selectedCategoryValues

        List of selected facets categories.

        Contains the actual values that were selected, indexed by facet. For example: "Location" => ("Sydney", "Melbourne").

      • facetsQueryConstraints

        private List<String> facetsQueryConstraints
        Query constraints to apply for faceted navigation (In addition to other query expressions).
      • facetCollectionConstraints

        @NonNull
        private @NonNull Optional<List<String>> facetCollectionConstraints
        The collections to restrict search to for faceted navigation. (In addition to other clive constraints).
        Since:
        15.12
      • facetsGScopeConstraints

        private String facetsGScopeConstraints
        GScope constraints to apply for faceted navigation (In addition to existing gscope constraints).
      • impersonated

        private boolean impersonated
        Whether the request is impersonated (Document Level Security)
      • requestId

        private String requestId
        Request identifier to log for this transaction. Depending on the collection configuration it can be an IP address, an md5 hash of the address, nothing ("-") or null.
        Since:
        12.4 - Renamed from userId, 12.5 - Renamed from userIdToLog
      • logQuery

        private Optional<Boolean> logQuery
        Defines if the query should be logged or not, or if it should fall back to default. If false this will prevent the query from being recorded in query logs as well as session history. If not set this will result in the defaults being used. For padre the default is to follow what is in collection.cfg, profile.cfg or padre_opts.cfg, otherwise if the log option is not set in any of those files padre will log the query. This will typically be set false for system generated searches or for extra searches. This may be set from groovy scripts. This can be set to false with cgi parameters on the admin side if the request is authenticated. To do this set &log=false in the URL.
        Since:
        15.14
      • inputParameters

        private final com.google.common.collect.ListMultimap<String,​String> inputParameters

        Raw input parameters

        Contains all the input parameters (query string / request parameters).

        Be aware that the value type is ListMultimap, thus a single key can have multiple values also ListMultimap.get(Object) will never return null.

        In freemarker to get the first value for a key or empty:

        
         question.inputParameters["query"]?first!
         

        In freemarker to test if the key exists and therefore has values:

        
         question.inputParameters?keys?seq_contains("query")
         

        In Java to replace all values for a key:

        
         inputParameters.replaceValues("query", List.of("my new query"))
         

        A clone of this map can be made with getInputParametersCopy().

        To convert such a map into a query string suitable for URLs, see QueryStringUtils#toString(ListMultimap, boolean)

        Since:
        16.0
      • queryStringMap

        @NonNull
        private @NonNull com.google.common.collect.ListMultimap<String,​String> queryStringMap

        Sets the query string parameter map.

        This is for internal use only and shouldn't be called outside of initializing the search question. Changing the query string map will affect all the URLs that are constructed in the data model

        Since:
        15.26
      • questionType

        private SearchQuestion.SearchQuestionType questionType

        Indicates the 'type' of question, which may trigger special processing in the search lifecycle.

        e.g. Extra searches or Content Auditor requests.

      • locale

        private Locale locale

        Locale to use for the search.

        This will affect the UI only, to configure the locale for the query processor please refer to the corresponding option -lang.

        Since:
        12.0
      • location

        private Location location

        Location information detected for the remote user based on information from their request.

        Since:
        13.0 (12.4 included a MaxMind location class directly here)
      • principal

        private Principal principal

        Principal representing the remote user for the current request.

        Will be NULL if the user isn't authenticated.

        Note: This is not included in the JSON / XML output for security reasons

        Since:
        12.2
      • hostname

        private String hostname

        Name of the host where PADRE executed the query.

        Since:
        14.0
      • funnelbackVersion

        private FunnelbackVersionI funnelbackVersion

        Funnelback version

        Since:
        15.12
      • maxPadrePacketSize

        private Optional<Integer> maxPadrePacketSize

        A optional maxPadrePacketSize which may be overridden to set the max Padre packet size that will be permitted. Generally the Config option ui.modern.padre_response_size_limit_bytes should be set in preference to setting this.

        Since:
        15.12
      • padreTimeout

        private Optional<Long> padreTimeout

        A optional timeout which when set overrides the value of collection.cfg option ui.modern.padre_fork_timeout_ms, which controls how long the main padre forking may take.

        Since:
        15.12
      • customData

        private final Map<String,​Object> customData
        Custom data placeholder allowing any arbitrary data to be stored by hook scripts.
        Since:
        15.12
    • Method Detail

      • getCurrentProfileConfig

        public ServiceConfig getCurrentProfileConfig()
        Returns the (modern) config of the currentProfile
      • getInputParametersCopy

        public com.google.common.collect.ListMultimap<String,​String> getInputParametersCopy()

        Returns a copy of the getInputParameters() map

        Be aware that the value type is ListMultimap, thus a single key can have multiple values also ListMultimap.get(Object) will never return null.

        Returns:
      • getQueryStringMapCopy

        public com.google.common.collect.ListMultimap<String,​String> getQueryStringMapCopy()

        Query string parameters as a Map

        Return a copy of the internal map representing the query string, for easy manipulation of individual parameters rather than having to decode the query string.

        The map is a copy intended to be modifiable to add/remove/update query string parameters.

        To convert such a map into a query string suitable for URLs, see QueryStringUtils#toString(MultiMap, boolean)

        Returns:
        Query string parameters
        Since:
        15.10
      • isExtraSearch

        @Deprecated
        public boolean isExtraSearch()
        Deprecated.
        As of release 14.2, replaced by questionType

        Indicates if this question is part of the "main" search, or part of an "extra" search.

        This is needed to perform some actions only on the main search but not for every extra search.

      • setExtraSearch

        @Deprecated
        public void setExtraSearch​(boolean isExtraSearch)
        Deprecated.
        As of release 14.2, replaced by questionType

        Sets whether this question is part of the "main" search, or part of an "extra" search.

      • getExecutionContext

        public ExecutionContext getExecutionContext()
        Execution context of the Search UI. Can be "admin" or "public", depending if the search is ran on the admin port or public port.
        Since:
        15.12
      • setExecutionContext

        public void setExecutionContext​(ExecutionContext executionContext)
        Execution context of the Search UI. Can be "admin" or "public", depending if the search is ran on the admin port or public port.
        Since:
        15.12
      • getRequestHeaders

        public com.google.common.collect.ListMultimap<String,​String> getRequestHeaders()
        Headers provided with the incoming search request
        Since:
        15.16
      • setRequestHeaders

        public void setRequestHeaders​(com.google.common.collect.ListMultimap<String,​String> requestHeaders)
        Headers provided with the incoming search request
        Since:
        15.16
      • getQuery

        public String getQuery()

        Query terms.

        This may be transformed before being passed to PADRE, depending on the configuration.

      • setQuery

        public void setQuery​(String query)

        Query terms.

        This may be transformed before being passed to PADRE, depending on the configuration.

      • getOriginalQuery

        public String getOriginalQuery()
        Original query, as entered by the user.
      • setOriginalQuery

        public void setOriginalQuery​(String originalQuery)
        Original query, as entered by the user.
      • getProfile

        @NonNull
        public @NonNull String getProfile()
        The profile to search with, defaulting to "_default".
      • setProfile

        public void setProfile​(@NonNull
                               @NonNull String profile)
        The profile to search with, defaulting to "_default".
      • getCurrentProfile

        public String getCurrentProfile()
        The profile which will be used for the request. This one will always correspond to the name of a profile which exists within the selected collection. Note that this may differ from profile if the requested profile does not actually exist on disk (in which case it will be set to DefaultValues.DEFAULT_PROFILE, as that is what's used).
        Since:
        15.12
      • setCurrentProfile

        public void setCurrentProfile​(String currentProfile)
        The profile which will be used for the request. This one will always correspond to the name of a profile which exists within the selected collection. Note that this may differ from profile if the requested profile does not actually exist on disk (in which case it will be set to DefaultValues.DEFAULT_PROFILE, as that is what's used).
        Since:
        15.12
      • getClive

        public String[] getClive()
        Specific component of a meta-collection to query
      • setClive

        public void setClive​(String[] clive)
        Specific component of a meta-collection to query
      • getForm

        @NonNull
        public @NonNull String getForm()
        Display form (template)
      • setForm

        public void setForm​(@NonNull
                            @NonNull String form)
        Display form (template)
      • getCnClickedCluster

        public String getCnClickedCluster()
        Contextual Navigation: last clicked cluster
      • setCnClickedCluster

        public void setCnClickedCluster​(String cnClickedCluster)
        Contextual Navigation: last clicked cluster
      • getCnPreviousClusters

        public List<String> getCnPreviousClusters()
        Contextual Navigation: Previous clicked clusters
      • getMetaParameters

        public List<String> getMetaParameters()

        meta_* / query_* input parameters, transformed in query expressions.

        Those parameters are supposed to be specified by the user, usually in an advanced search form. If you need to inject parameters for technical / behind-the-scene reasons, consider using systemMetaParameters.

        See Also:
        systemMetaParameters
      • getSystemMetaParameters

        public List<String> getSystemMetaParameters()

        smeta_* / squery_* input parameters, transformed in query expressions.

        Those parameters are supposed to be "technical" parameters, usually injected through a hook script. If you want the user to specify parameters, consider using metaParameters.

        Since:
        12.2
        See Also:
        metaParameters
      • getAdditionalParameters

        public Map<String,​String[]> getAdditionalParameters()

        Additional parameters to pass as-is to PADRE.

        The values of this map will be passed through to PADRE and won't be processed at all by the Modern UI. Only parameters relevant to PADRE should be injected here.

        Depending on the parameters you want to inject or manipulate, consider using inputParameters. Those parameters will be processed by the Modern UI (For example to inject faceted navigation constraints).

        Note that this map is populated before the first hook script is run: Any additional parameter injected in inputParameters in a hook script won't be copied to this map.

      • getEnvironmentVariables

        public Map<String,​String> getEnvironmentVariables()
        List of environment variables to pass to PADRE.
      • getDynamicQueryProcessorOptions

        public List<String> getDynamicQueryProcessorOptions()

        Dynamic query processor options for PADRE, in addition to the one set in collection.cfg.

        Will be updated by the input processing.

      • getPriorityQueryProcessorOptions

        public PriorityQueryProcessorOptions getPriorityQueryProcessorOptions()
        Query processor options that are guaranteed to apply.

        Internal use only

        Since:
        15.12
      • getUserKeys

        public List<String> getUserKeys()

        User keys for early binding Document Level Security.

      • getSelectedFacets

        public Set<String> getSelectedFacets()

        List of selected facets.

        Contains the name of the facets that were selected, such as "Location" or "Brand", but not the actual value.

      • getSelectedCategoryValues

        public Map<String,​List<String>> getSelectedCategoryValues()

        List of selected facets categories.

        Contains the actual values that were selected, indexed by facet. For example: "Location" => ("Sydney", "Melbourne").

      • getFacetsQueryConstraints

        public List<String> getFacetsQueryConstraints()
        Query constraints to apply for faceted navigation (In addition to other query expressions).
      • setFacetsQueryConstraints

        public void setFacetsQueryConstraints​(List<String> facetsQueryConstraints)
        Query constraints to apply for faceted navigation (In addition to other query expressions).
      • getFacetCollectionConstraints

        @NonNull
        public @NonNull Optional<List<String>> getFacetCollectionConstraints()
        The collections to restrict search to for faceted navigation. (In addition to other clive constraints).
        Since:
        15.12
      • setFacetCollectionConstraints

        public void setFacetCollectionConstraints​(@NonNull
                                                  @NonNull Optional<List<String>> facetCollectionConstraints)
        The collections to restrict search to for faceted navigation. (In addition to other clive constraints).
        Since:
        15.12
      • setFacetsGScopeConstraints

        public void setFacetsGScopeConstraints​(String facetsGScopeConstraints)
        GScope constraints to apply for faceted navigation (In addition to existing gscope constraints).
      • getFacetsGScopeConstraints

        public String getFacetsGScopeConstraints()
        GScope constraints to apply for faceted navigation (In addition to existing gscope constraints).
      • isImpersonated

        public boolean isImpersonated()
        Whether the request is impersonated (Document Level Security)
      • setImpersonated

        public void setImpersonated​(boolean impersonated)
        Whether the request is impersonated (Document Level Security)
      • getRequestId

        public String getRequestId()
        Request identifier to log for this transaction. Depending on the collection configuration it can be an IP address, an md5 hash of the address, nothing ("-") or null.
        Since:
        12.4 - Renamed from userId, 12.5 - Renamed from userIdToLog
      • setRequestId

        public void setRequestId​(String requestId)
        Request identifier to log for this transaction. Depending on the collection configuration it can be an IP address, an md5 hash of the address, nothing ("-") or null.
        Since:
        12.4 - Renamed from userId, 12.5 - Renamed from userIdToLog
      • getLogQuery

        public Optional<Boolean> getLogQuery()
        Defines if the query should be logged or not, or if it should fall back to default. If false this will prevent the query from being recorded in query logs as well as session history. If not set this will result in the defaults being used. For padre the default is to follow what is in collection.cfg, profile.cfg or padre_opts.cfg, otherwise if the log option is not set in any of those files padre will log the query. This will typically be set false for system generated searches or for extra searches. This may be set from groovy scripts. This can be set to false with cgi parameters on the admin side if the request is authenticated. To do this set &log=false in the URL.
        Since:
        15.14
      • setLogQuery

        public void setLogQuery​(Optional<Boolean> logQuery)
        Defines if the query should be logged or not, or if it should fall back to default. If false this will prevent the query from being recorded in query logs as well as session history. If not set this will result in the defaults being used. For padre the default is to follow what is in collection.cfg, profile.cfg or padre_opts.cfg, otherwise if the log option is not set in any of those files padre will log the query. This will typically be set false for system generated searches or for extra searches. This may be set from groovy scripts. This can be set to false with cgi parameters on the admin side if the request is authenticated. To do this set &log=false in the URL.
        Since:
        15.14
      • getInputParameters

        public com.google.common.collect.ListMultimap<String,​String> getInputParameters()

        Raw input parameters

        Contains all the input parameters (query string / request parameters).

        Be aware that the value type is ListMultimap, thus a single key can have multiple values also ListMultimap.get(Object) will never return null.

        In freemarker to get the first value for a key or empty:

        
         question.inputParameters["query"]?first!
         

        In freemarker to test if the key exists and therefore has values:

        
         question.inputParameters?keys?seq_contains("query")
         

        In Java to replace all values for a key:

        
         inputParameters.replaceValues("query", List.of("my new query"))
         

        A clone of this map can be made with getInputParametersCopy().

        To convert such a map into a query string suitable for URLs, see QueryStringUtils#toString(ListMultimap, boolean)

        Since:
        16.0
      • setQueryStringMap

        public void setQueryStringMap​(@NonNull
                                      @NonNull com.google.common.collect.ListMultimap<String,​String> queryStringMap)

        Sets the query string parameter map.

        This is for internal use only and shouldn't be called outside of initializing the search question. Changing the query string map will affect all the URLs that are constructed in the data model

        Since:
        15.26
      • getQuestionType

        public SearchQuestion.SearchQuestionType getQuestionType()

        Indicates the 'type' of question, which may trigger special processing in the search lifecycle.

        e.g. Extra searches or Content Auditor requests.

      • setQuestionType

        public void setQuestionType​(SearchQuestion.SearchQuestionType questionType)

        Indicates the 'type' of question, which may trigger special processing in the search lifecycle.

        e.g. Extra searches or Content Auditor requests.

      • getLocale

        public Locale getLocale()

        Locale to use for the search.

        This will affect the UI only, to configure the locale for the query processor please refer to the corresponding option -lang.

        Since:
        12.0
      • setLocale

        public void setLocale​(Locale locale)

        Locale to use for the search.

        This will affect the UI only, to configure the locale for the query processor please refer to the corresponding option -lang.

        Since:
        12.0
      • getLocation

        public Location getLocation()

        Location information detected for the remote user based on information from their request.

        Since:
        13.0 (12.4 included a MaxMind location class directly here)
      • setLocation

        public void setLocation​(Location location)

        Location information detected for the remote user based on information from their request.

        Since:
        13.0 (12.4 included a MaxMind location class directly here)
      • getPrincipal

        public Principal getPrincipal()

        Principal representing the remote user for the current request.

        Will be NULL if the user isn't authenticated.

        Note: This is not included in the JSON / XML output for security reasons

        Since:
        12.2
      • setPrincipal

        public void setPrincipal​(Principal principal)

        Principal representing the remote user for the current request.

        Will be NULL if the user isn't authenticated.

        Note: This is not included in the JSON / XML output for security reasons

        Since:
        12.2
      • getHostname

        public String getHostname()

        Name of the host where PADRE executed the query.

        Since:
        14.0
      • setHostname

        public void setHostname​(String hostname)

        Name of the host where PADRE executed the query.

        Since:
        14.0
      • getFunnelbackVersion

        public FunnelbackVersionI getFunnelbackVersion()

        Funnelback version

        Since:
        15.12
      • setFunnelbackVersion

        public void setFunnelbackVersion​(FunnelbackVersionI funnelbackVersion)

        Funnelback version

        Since:
        15.12
      • getMaxPadrePacketSize

        public Optional<Integer> getMaxPadrePacketSize()

        A optional maxPadrePacketSize which may be overridden to set the max Padre packet size that will be permitted. Generally the Config option ui.modern.padre_response_size_limit_bytes should be set in preference to setting this.

        Since:
        15.12
      • setMaxPadrePacketSize

        public void setMaxPadrePacketSize​(Optional<Integer> maxPadrePacketSize)

        A optional maxPadrePacketSize which may be overridden to set the max Padre packet size that will be permitted. Generally the Config option ui.modern.padre_response_size_limit_bytes should be set in preference to setting this.

        Since:
        15.12
      • getPadreTimeout

        public Optional<Long> getPadreTimeout()

        A optional timeout which when set overrides the value of collection.cfg option ui.modern.padre_fork_timeout_ms, which controls how long the main padre forking may take.

        Since:
        15.12
      • setPadreTimeout

        public void setPadreTimeout​(Optional<Long> padreTimeout)

        A optional timeout which when set overrides the value of collection.cfg option ui.modern.padre_fork_timeout_ms, which controls how long the main padre forking may take.

        Since:
        15.12
      • getCustomData

        public Map<String,​Object> getCustomData()
        Custom data placeholder allowing any arbitrary data to be stored by hook scripts.
        Since:
        15.12