Package com.day.cq.wcm.foundation
Class Search
java.lang.Object
com.day.cq.wcm.foundation.Search
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classA hit within the search result.final classA result page.final classA search result. -
Constructor Summary
ConstructorsConstructorDescriptionSearch(SlingHttpServletRequest request) Creates a new search based on the givenrequest. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.since 5.2.longgetQuery()voidsetExcerptPropertyNames(String properties) Deprecated.since 5.2.voidsetHitsPerPage(long num) voidSets a new fulltext query that will be executed.voidsetSearchIn(String searchIn) voidsetSearchProperties(String properties)
-
Constructor Details
-
Search
Creates a new search based on the givenrequest.- Parameters:
request- the current request.
-
-
Method Details
-
getTrends
- Returns:
- query trends (popular queries).
-
getResult
- Returns:
- the query result or
nullif there is neither a query parameter set nor a tag predicate. - Throws:
RepositoryException- if an exception occurs while executing the query.
-
getRelatedQueries
- Returns:
- queries that are related to the current one.
- Throws:
RepositoryException- if an error occurs while reading from the repository.
-
getQuery
- Returns:
- the query supplied by the user or an empty String if none is provided.
-
setQuery
Sets a new fulltext query that will be executed.- Parameters:
query- the fulltext query.
-
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.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
- Returns:
- the location where to search in.
-
setSearchIn
- Parameters:
searchIn- the location where to search in.
-
getSearchProperties
- Returns:
- the names of the properties that will be searched.
-
setSearchProperties
- Parameters:
properties- comma separated names of the properties that will be searched.
-