Package com.day.cq.wcm.foundation
Class Search
- java.lang.Object
-
- com.day.cq.wcm.foundation.Search
-
public final class Search extends java.lang.Object
TheSearch
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 useQueryBuilder
or execute a query directly on the JCR Session if wildcard support is needed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Search.Hit
A hit within the search result.class
Search.Page
A result page.class
Search.Result
A search result.
-
Constructor Summary
Constructors Constructor Description Search(SlingHttpServletRequest request)
Creates a new search based on the givenrequest
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String
getExcerptPropertyNames()
Deprecated.since 5.2.long
getHitsPerPage()
java.lang.String
getQuery()
java.util.List<java.lang.String>
getRelatedQueries()
Search.Result
getResult()
java.lang.String
getSearchIn()
java.lang.String
getSearchProperties()
Trends
getTrends()
void
setExcerptPropertyNames(java.lang.String properties)
Deprecated.since 5.2.void
setHitsPerPage(long num)
void
setQuery(java.lang.String query)
Sets a new fulltext query that will be executed.void
setSearchIn(java.lang.String searchIn)
void
setSearchProperties(java.lang.String properties)
-
-
-
Constructor Detail
-
Search
public Search(SlingHttpServletRequest request)
Creates a new search based on the givenrequest
.- Parameters:
request
- the current request.
-
-
Method Detail
-
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 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.
-
-