Class SearchDataProvider

    • Field Detail

      • SOURCE_PARAMETER_NAME_SCOPE_SERVICE_INSTANCE

        public static final String SOURCE_PARAMETER_NAME_SCOPE_SERVICE_INSTANCE
        See Also:
        Constant Field Values
      • SOURCE_PARAMETER_NAME_AGGREGATIONS

        public static final String SOURCE_PARAMETER_NAME_AGGREGATIONS
        Name of the parameter that holds the aggregations that should be performed during search.
        Since:
        9.0.0
        See Also:
        Constant Field Values
      • SOURCE_PARAMETER_NAME_AGGREGATED_VALUES

        public static final String SOURCE_PARAMETER_NAME_AGGREGATED_VALUES
        Name of the parameter that holds the aggregated values (user's filters).
        Since:
        9.0.0
        See Also:
        Constant Field Values
      • SOURCE_PARAMETER_TARGET_OBJECTS_SOURCE_ID

        public static final String SOURCE_PARAMETER_TARGET_OBJECTS_SOURCE_ID
        See Also:
        Constant Field Values
    • Constructor Detail

      • SearchDataProvider

        public SearchDataProvider()
    • Method Detail

      • hasUserQueryChanged

        protected boolean hasUserQueryChanged​(SearchSource searchSource)
        Returns whether the user query parameter has changed for the current request.
        Parameters:
        searchSource - the search source.
        Returns:
        true if the user query parameter has changed, false otherwise.
        Since:
        10.4.0
      • getSearchMonitor

        protected IMonitor getSearchMonitor​(String userQuery,
                                            String unparsedUserQuery,
                                            SearchSource searchSource,
                                            ITransaction transaction)
                                     throws PortalException
        Returns the monitor object to be used in monitoring or null if the search will not be monitored.
        Parameters:
        userQuery - the user query (extracted from unparsed user query).
        unparsedUserQuery - the unparsed user query.
        searchSource - the search source
        transaction - the transaction.
        Returns:
        the monitor object to be used in monitoring or null if the search will not be monitored.
        Throws:
        PortalException
        Since:
        10.1.0
      • parseUserQuery

        protected SearchDataProvider.ParsedUserQuery parseUserQuery​(String query)
        Parse the given user query to generate a parsed version of it. This method must not return null.

        The default implementation follows the following rules:

        • Creates tag filters (ContentLocaleFields#TAG_NORMALIZED_NAME), identifying them by terms starting with #. The # char must be followed by a letter char. All chars after # char, that are alphanumeric will be identified as a tag filter. The tags filters will be transformed in lower case. All tags filters will be removed from user query and filters to the tag normalized name field will be created using them.
        • The remaining user query will be trimmed and multiple spaces will be transformed in a single space char.

        For example:
        For the user query Seattle Seahawks #nfl #twelves #Love#NFL #"GoHawks", the parsed user query would be:
        User query
        Seattle Seahawks #"GoHawks"
        Tags filters
        • nfl
        • twelves
        • love
        Note that #NFL is the same as #nfl and was not added again.
        Parameters:
        query - the user query.
        Returns:
        the parsed user query.
        Since:
        9.0.0
      • getHighlightConfiguration

        protected HighlightConfig getHighlightConfiguration()
        Returns the highlight configuration.
        Returns:
        the highlight configuration.
        Since:
        8.1.0
      • getPublishedContextIdsIncludedInSearch

        protected Collection<String> getPublishedContextIdsIncludedInSearch​(SearchSource searchSource,
                                                                            ServiceInstanceConfig searchServiceInstanceConfig)
                                                                     throws PortalException
        Returns the identifiers of the published contexts that should be included in search. This method is not supposed to return null. If no published contexts should be included, an empty set should be returned instead.
        Parameters:
        searchSource - the search source.
        searchServiceInstanceConfig - the search service instance.
        Returns:
        the identifiers of the published contexts that should be included in search.
        Throws:
        PortalException
        Since:
        8.1.0
      • populateRow

        protected void populateRow​(SessionConfig sessionConfig,
                                   ISourceData row,
                                   ISearchHit hit,
                                   Set<String> fieldIds,
                                   SearchSource searchSource,
                                   ITransaction transaction)
                            throws PortalException
        Populate the given row with the given search hit.
        Parameters:
        sessionConfig - the user's session.
        row - the row to be populated.
        hit - the search hit.
        fieldIds - the source fields identifiers.
        searchSource - the source.
        transaction - the transaction.
        Throws:
        PortalException
        Since:
        8.1.0
      • getHighlight

        protected Object getHighlight​(ISearchHit hit,
                                      ISourceData row)
        Returns the highlight value for the given row.
        Parameters:
        hit - the search hit.
        row - the row.
        Returns:
        the highlight value for the given row.
        Since:
        8.1.0
      • getPublications

        protected Object getPublications​(ISearchHit hit,
                                         ISourceData row,
                                         SearchSource searchSource)
                                  throws PortalException
        Returns the publications of the given search hit.
        Parameters:
        hit - the search hit.
        row - the row being processed.
        searchSource - the search source.
        Returns:
        the publications of the given search hit.
        Throws:
        PortalException
        Since:
        8.1.0
      • populateRowField

        protected void populateRowField​(SessionConfig sessionConfig,
                                        ISourceData row,
                                        ISearchHit hit,
                                        String fieldId,
                                        SearchSource searchSource,
                                        ITransaction transaction)
                                 throws PortalException
        Populates the given field within the row with the given hit.
        Parameters:
        sessionConfig - the user's session.
        row - the row to be populated.
        hit - the search hit.
        fieldId - the identifier of the field currently being populated.
        searchSource - the search source.
        transaction - the transaction.
        Throws:
        PortalException
        Since:
        8.1.0
      • getMainPublishedContextUrlValue

        protected String getMainPublishedContextUrlValue​(ISearchHit hit)
                                                  throws PortalException
        Returns the main context URL value that user has access permission.
        Parameters:
        hit - the search hit.
        Returns:
        the main context URL value that user has access permission.
        Throws:
        PortalException
        Since:
        8.1.0
      • getSearchSorts

        protected List<SearchQuerySort> getSearchSorts​(SessionConfig sessionConfig,
                                                       SearchSource searchSource,
                                                       ServiceInstanceConfig searchServiceInstanceConfig,
                                                       ITransaction transaction)
        Returns the search's sorts. This method is not supposed to return null. If no sort is to be applied in search, an empty list should be returned instead.
        Parameters:
        sessionConfig - the user's session.
        searchSource - the search source.
        searchServiceInstanceConfig - the search service instance.
        transaction - the transaction.
        Returns:
        the search's sorts
        Since:
        8.1.0
        See Also:
        SearchQuerySort, SearchQuery#addSort(SearchQuerySort)
      • getUserQuery

        protected String getUserQuery​(SessionConfig sessionConfig,
                                      SearchSource searchSource,
                                      ITransaction transaction)
        Returns the user query to be used in search. If no user query was provided, null should be returned.
        Parameters:
        sessionConfig - the user's session.
        searchSource - the search source.
        transaction - the transaction.
        Returns:
        the user query to be used in search.
        Since:
        8.1.0
        See Also:
        SearchQuery.setUserQuery(String)
      • getSearchFieldIds

        protected Set<String> getSearchFieldIds​(SessionConfig sessionConfig,
                                                SearchSource searchSource,
                                                ITransaction transaction)
        Returns the search fields identifiers. The default behavior is to get the source's fields identifiers.
        Parameters:
        sessionConfig - the user's session.
        searchSource - the search source.
        transaction - the transaction.
        Returns:
        the search fields identifiers.
        Since:
        8.1.0
      • getSearchServiceInstance

        protected ServiceInstanceConfig getSearchServiceInstance​(SessionConfig sessionConfig,
                                                                 SearchSource searchSource,
                                                                 ITransaction transaction)
                                                          throws PortalException
        Returns the search service instance. This method is not supposed to return null.
        Parameters:
        sessionConfig - the user's session.
        searchSource - the search source.
        transaction - the transaction.
        Returns:
        the search service instance.
        Throws:
        PortalException
        Since:
        8.1.0