Class Search

java.lang.Object
com.day.cq.wcm.foundation.Search

public final class Search extends 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 Details

    • Search

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

    • getTrends

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

      public Search.Result getResult() throws RepositoryException
      Returns:
      the query result or null if there is neither a query parameter set nor a tag predicate.
      Throws:
      RepositoryException - if an exception occurs while executing the query.
    • getRelatedQueries

      public List<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 String getQuery()
      Returns:
      the query supplied by the user or an empty String if none is provided.
    • setQuery

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

      @Deprecated public 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(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 String getSearchIn()
      Returns:
      the location where to search in.
    • setSearchIn

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

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

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