Interface SimpleSearch
-
public interface SimpleSearch
Search
implements 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, seeQuery
and theQueryBuilder
.- Since:
- 5.2
-
-
Field Summary
Fields Modifier and Type Field Description static String
RELATED_PREFIX
The prefix for a query searches for similar content.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addPredicate(Predicate predicate)
Allows to add custom predicates for the underlyingQuery
.long
getHitsPerPage()
Returns the number of hits to include perResultPage
, ie.String
getQuery()
Returns the query term supplied by the user.List<String>
getRelatedQueries()
Returns queries that are related to the current one.SearchResult
getResult()
Returns the search result object.String
getSearchIn()
Returns the repository path where to search in.String
getSearchProperties()
Returns the comma-separated list of properties that will be searched for the term given insetQuery(String)
.long
getStart()
Returns the offset in the actual search results to start from.Trends
getTrends()
Returns a object with access to query trend statistics.void
setHitsPerPage(long num)
Sets the number of hits to include on aResultPage
.void
setQuery(String query)
Sets a new fulltext query that will be executed.void
setSearchIn(String searchIn)
Sets the repository path where to search in.void
setSearchProperties(String properties)
Sets the comma-separated list of properties that will be searched for the term given insetQuery(String)
.void
setStart(long start)
This sets an offset for the actual search results, ie.
-
-
-
Field Detail
-
RELATED_PREFIX
static final String RELATED_PREFIX
The prefix for a query searches for similar content.- See Also:
- Constant Field Values
-
-
Method Detail
-
setQuery
void setQuery(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
String getQuery()
Returns the query term supplied by the user.- Returns:
- the query term supplied by the user.
-
setSearchIn
void setSearchIn(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
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 page
or by running a new query and setting thestart
parameter (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 RepositoryException
Returns the search result object. The query is only executed once upon the first call to this method.- Returns:
- the query result or
null
if there is no query parameter set. - Throws:
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
List<String> getRelatedQueries() throws RepositoryException
Returns queries that are related to the current one.- Returns:
- queries that are related to the current one.
- Throws:
RepositoryException
- if an error occurs while reading from the repository.
-
setSearchProperties
void setSearchProperties(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
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.
-
-