com.day.cq.search.impl
Class SimpleSearchImpl

java.lang.Object
  extended by com.day.cq.search.impl.SimpleSearchImpl
All Implemented Interfaces:
SimpleSearch

public class SimpleSearchImpl
extends Object
implements SimpleSearch

Search is the implementation of the simple SimpleSearch interface, using a Query under the hood.


Field Summary
 
Fields inherited from interface com.day.cq.search.SimpleSearch
RELATED_PREFIX
 
Constructor Summary
SimpleSearchImpl(org.apache.sling.api.resource.Resource resource, QueryBuilder builder, StatisticsService statsService)
          Default constructor.
 
Method Summary
 void addPredicate(Predicate predicate)
          Allows to add custom predicates for the underlying Query.
 String getExcerptPropertyNames()
           
 long getHitsPerPage()
           
 String getQuery()
           
 List<String> getRelatedQueries()
           
 SearchResult getResult()
           
 String getSearchIn()
           
 String getSearchProperties()
           
 long getStart()
           
 Trends getTrends()
           
 void setExcerptPropertyNames(String properties)
           
 void setHitsPerPage(long num)
           
 void setQuery(String query)
          Sets a new fulltext query that will be executed.
 void setSearchIn(String searchIn)
           
 void setSearchProperties(String properties)
           
 void setStart(long start)
          This sets an offset for the actual search results, ie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSearchImpl

public SimpleSearchImpl(org.apache.sling.api.resource.Resource resource,
                        QueryBuilder builder,
                        StatisticsService statsService)
Default constructor. Initializes the content with default values.

Parameters:
resource - the current resource.
builder - the query builder
statsService - the statistics service.
Method Detail

getResult

public SearchResult getResult()
                       throws RepositoryException
Specified by:
getResult in interface SimpleSearch
Returns:
the query result or null if there is no query parameter set.
Throws:
RepositoryException - if an exception occurs while executing the query.

getTrends

public Trends getTrends()
Specified by:
getTrends in interface SimpleSearch
Returns:
query trends (popular queries).

getRelatedQueries

public List<String> getRelatedQueries()
                               throws RepositoryException
Specified by:
getRelatedQueries in interface SimpleSearch
Returns:
queries that are related to the current one.
Throws:
RepositoryException - if an error occurs while reading from the repository.

getQuery

public String getQuery()
Specified by:
getQuery in interface SimpleSearch
Returns:
the fulltext query that will be executed.

setQuery

public void setQuery(String query)
Sets a new fulltext query that will be executed.

Specified by:
setQuery in interface SimpleSearch
Parameters:
query - the fulltext query.

getHitsPerPage

public long getHitsPerPage()
Specified by:
getHitsPerPage in interface SimpleSearch
Returns:
the number of hits to display per page.

setHitsPerPage

public void setHitsPerPage(long num)
Specified by:
setHitsPerPage in interface SimpleSearch
Parameters:
num - the number of hits to display on a page.

getSearchIn

public String getSearchIn()
Specified by:
getSearchIn in interface SimpleSearch
Returns:
the location where to search in. The default location is derived from the resource passed in the constructor.

setSearchIn

public void setSearchIn(String searchIn)
Specified by:
setSearchIn in interface SimpleSearch
Parameters:
searchIn - the location where to search in.

getSearchProperties

public String getSearchProperties()
Specified by:
getSearchProperties in interface SimpleSearch
Returns:
the names of the properties that will be searched.

setSearchProperties

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

getExcerptPropertyNames

public String getExcerptPropertyNames()
Specified by:
getExcerptPropertyNames in interface SimpleSearch
Returns:
the names of the properties that will be used in an excerpt.

setExcerptPropertyNames

public void setExcerptPropertyNames(String properties)
Specified by:
setExcerptPropertyNames in interface SimpleSearch
Parameters:
properties - comma separated names of the properties that will be used in an excerpt.

getStart

public long getStart()
Specified by:
getStart in interface SimpleSearch
Returns:
offset in the actual search results to start from

setStart

public void setStart(long start)
Description copied from interface: SimpleSearch
This sets an offset for the actual search results, ie. it will skip the first N (= start) items of the underlying result iterator.

Specified by:
setStart in interface SimpleSearch
Parameters:
start - the offset in the actual search results to start from

addPredicate

public void addPredicate(Predicate predicate)
Description copied from interface: SimpleSearch
Allows to add custom predicates for the underlying Query.

Specified by:
addPredicate in interface SimpleSearch
Parameters:
predicate - a search predicate


Copyright © 2009 Day Management AG. All Rights Reserved.