Class Search


  • public final class Search
    extends java.lang.Object
    The Search class implements the search logic used in the foundation search component and exposes the query result in a scripting friendly object structure. This class does a fulltext query, which means wildcards like '*' and '?' will be filtered out. Please use QueryBuilder or execute a query directly on the JCR Session if wildcard support is needed.
    • Constructor Detail

      • Search

        public Search​(SlingHttpServletRequest request)
        Creates a new search based on the given request.
        Parameters:
        request - the current request.
    • Method Detail

      • getTrends

        public Trends getTrends()
        Returns:
        query trends (popular queries).
      • getRelatedQueries

        public java.util.List<java.lang.String> getRelatedQueries()
                                                           throws RepositoryException
        Returns:
        queries that are related to the current one.
        Throws:
        RepositoryException - if an error occurs while reading from the repository.
      • getQuery

        public java.lang.String getQuery()
        Returns:
        the query supplied by the user or an empty String if none is provided.
      • setQuery

        public void setQuery​(java.lang.String query)
        Sets a new fulltext query that will be executed.
        Parameters:
        query - the fulltext query.
      • getExcerptPropertyNames

        @Deprecated
        public java.lang.String getExcerptPropertyNames()
        Deprecated.
        since 5.2. Excerpt properties can now only be specified in the configuration of the QueryBuilder interface. For 5.3, when Jackrabbit 1.5 is used, the excerpt properties can be configured in the repository.
        Returns:
        the names of the properties that will be used in an excerpt.
      • setExcerptPropertyNames

        @Deprecated
        public void setExcerptPropertyNames​(java.lang.String properties)
        Deprecated.
        since 5.2. Excerpt properties can now only be specified in the configuration of the QueryBuilder interface. For 5.3, when Jackrabbit 1.5 is used, the excerpt properties can be configured in the repository.
        Parameters:
        properties - comma separated names of the properties that will be used in an excerpt.
      • getHitsPerPage

        public long getHitsPerPage()
        Returns:
        the number of hits to display per page.
      • setHitsPerPage

        public void setHitsPerPage​(long num)
        Parameters:
        num - the number of hits to display on a page.
      • getSearchIn

        public java.lang.String getSearchIn()
        Returns:
        the location where to search in.
      • setSearchIn

        public void setSearchIn​(java.lang.String searchIn)
        Parameters:
        searchIn - the location where to search in.
      • getSearchProperties

        public java.lang.String getSearchProperties()
        Returns:
        the names of the properties that will be searched.
      • setSearchProperties

        public void setSearchProperties​(java.lang.String properties)
        Parameters:
        properties - comma separated names of the properties that will be searched.