Interface SimpleSearch
- 
public interface SimpleSearchSearchimplements a simple fulltext search with some additions to the search logic and exposes the query result in a scripting friendly object structure. For more complex queries, seeQueryand theQueryBuilder.- Since:
 - 5.2
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringRELATED_PREFIXThe prefix for a query searches for similar content. 
- 
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddPredicate(Predicate predicate)Allows to add custom predicates for the underlyingQuery.longgetHitsPerPage()Returns the number of hits to include perResultPage, ie.java.lang.StringgetQuery()Returns the query term supplied by the user.java.util.List<java.lang.String>getRelatedQueries()Returns queries that are related to the current one.SearchResultgetResult()Returns the search result object.java.lang.StringgetSearchIn()Returns the repository path where to search in.java.lang.StringgetSearchProperties()Returns the comma-separated list of properties that will be searched for the term given insetQuery(String).longgetStart()Returns the offset in the actual search results to start from.TrendsgetTrends()Returns a object with access to query trend statistics.voidsetHitsPerPage(long num)Sets the number of hits to include on aResultPage.voidsetQuery(java.lang.String query)Sets a new fulltext query that will be executed.voidsetSearchIn(java.lang.String searchIn)Sets the repository path where to search in.voidsetSearchProperties(java.lang.String properties)Sets the comma-separated list of properties that will be searched for the term given insetQuery(String).voidsetStart(long start)This sets an offset for the actual search results, ie. 
 - 
 
- 
- 
Field Detail
- 
RELATED_PREFIX
static final java.lang.String RELATED_PREFIX
The prefix for a query searches for similar content.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
setQuery
void setQuery(java.lang.String query)
Sets a new fulltext query that will be executed.If this is called after
getResult()has been called, i.e. the query was executed already, this will lead to the nextgetResult()call executing the new query again.- Parameters:
 query- the fulltext query.
 
- 
getQuery
java.lang.String getQuery()
Returns the query term supplied by the user.- Returns:
 - the query term supplied by the user.
 
 
- 
setSearchIn
void setSearchIn(java.lang.String searchIn)
Sets the repository path where to search in. This allows to specify a subtree such as "/content/mysite".If this is called after
getResult()has been called, i.e. the query was executed already, this will lead to the nextgetResult()call executing the new query again.- Parameters:
 searchIn- the location where to search in.
 
- 
getSearchIn
java.lang.String getSearchIn()
Returns the repository path where to search in.- Returns:
 - the location where to search in.
 
 
- 
setHitsPerPage
void setHitsPerPage(long num)
Sets the number of hits to include on aResultPage. Since only the first page is returned directly and typically fully read by clients, this can also be seen as "limit" for the search result. Further results can be accessed either by retrieving thenext result pageor by running a new query and setting thestartparameter (often also called "offset"). For unlimited results on a single page, use 0. Default value is 10.If this is called after
getResult()has been called, i.e. the query was executed already, this will lead to the nextgetResult()call executing the new query again.- Parameters:
 num- the number of hits to include on a result page (0 for unlimited results)
 
- 
getHitsPerPage
long getHitsPerPage()
Returns the number of hits to include perResultPage, ie. the limit. SeesetHitsPerPage(long).- Returns:
 - the number of hits to include per result page
 
 
- 
setStart
void setStart(long start)
This sets an offset for the actual search results, ie. it will skip the first N (=start) items of the underlying result iterator. By default this is 0, ie. right from the very beginning.If this is called after
getResult()has been called, i.e. the query was executed already, this will lead to the nextgetResult()call executing the new query again.- Parameters:
 start- the offset in the actual search results to start from
 
- 
getStart
long getStart()
Returns the offset in the actual search results to start from. SeesetStart(long).- Returns:
 - offset in the actual search results to start from
 
 
- 
addPredicate
void addPredicate(Predicate predicate)
Allows to add custom predicates for the underlyingQuery.If this is called after
getResult()has been called, i.e. the query was executed already, this will lead to the nextgetResult()call executing the new query again.- Parameters:
 predicate- a search predicate
 
- 
getResult
SearchResult getResult() throws javax.jcr.RepositoryException
Returns the search result object. The query is only executed once upon the first call to this method.- Returns:
 - the query result or 
nullif there is no query parameter set. - Throws:
 javax.jcr.RepositoryException- if an exception occurs while executing the query.
 
- 
getTrends
Trends getTrends()
Returns a object with access to query trend statistics.- Returns:
 - query trends (popular queries).
 
 
- 
getRelatedQueries
java.util.List<java.lang.String> getRelatedQueries() throws javax.jcr.RepositoryExceptionReturns queries that are related to the current one.- Returns:
 - queries that are related to the current one.
 - Throws:
 javax.jcr.RepositoryException- if an error occurs while reading from the repository.
 
- 
setSearchProperties
void setSearchProperties(java.lang.String properties)
Sets the comma-separated list of properties that will be searched for the term given insetQuery(String).If this is called after
getResult()has been called, i.e. the query was executed already, this will lead to the nextgetResult()call executing the new query again.- Parameters:
 properties- comma separated names of the properties that will be searched.
 
- 
getSearchProperties
java.lang.String getSearchProperties()
Returns the comma-separated list of properties that will be searched for the term given insetQuery(String).- Returns:
 - the names of the properties that will be searched.
 
 
 - 
 
 -