com.day.cq.wcm.foundation
Class Search

java.lang.Object
  extended by com.day.cq.wcm.foundation.Search

public final class Search
extends Object

Search implements the search logic and exposes the query result in a scripting friendly object structure.


Nested Class Summary
 class Search.Hit
          A hit within the search result.
 class Search.Page
          A result page.
 class Search.Result
          A search result.
 
Field Summary
static String FROM_FACET_PARAM_NAME
          The name for the last modified facet parameter, which specifies the lower bound of the date range.
static String LANGUAGE_FACET_PARAM_NAME
          The name for the language facet parameter.
static String MIME_TYPE_FACET_PARAM_NAME
          The name for the mime type facet parameter.
static String QUERY_PARAM_NAME
          The name for the query parameter.
static String START_PARAM_NAME
          The name for the start parameter.
static String TAG_FACET_PARAM_NAME
          The name for the tag facet parameter.
static String TO_FACET_PARAM_NAME
          The name for the last modified facet parameter, which specifies the upper bound of the date range.
 
Constructor Summary
Search(org.apache.sling.api.SlingHttpServletRequest request)
          Creates a new search based on the given request.
 
Method Summary
protected  void appendConstraints(StringBuffer stmt, String relPath, String[] values)
          Appends value constraints for the property with the given relPath.
 String getExcerptPropertyNames()
           
 long getHitsPerPage()
           
 String getQuery()
           
 List<String> getRelatedQueries()
           
 Search.Result getResult()
           
 String getSearchIn()
           
 String getSearchProperties()
           
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERY_PARAM_NAME

public static final String QUERY_PARAM_NAME
The name for the query parameter.

See Also:
Constant Field Values

START_PARAM_NAME

public static final String START_PARAM_NAME
The name for the start parameter.

See Also:
Constant Field Values

LANGUAGE_FACET_PARAM_NAME

public static final String LANGUAGE_FACET_PARAM_NAME
The name for the language facet parameter.

See Also:
Constant Field Values

TAG_FACET_PARAM_NAME

public static final String TAG_FACET_PARAM_NAME
The name for the tag facet parameter.

See Also:
Constant Field Values

MIME_TYPE_FACET_PARAM_NAME

public static final String MIME_TYPE_FACET_PARAM_NAME
The name for the mime type facet parameter.

See Also:
Constant Field Values

FROM_FACET_PARAM_NAME

public static final String FROM_FACET_PARAM_NAME
The name for the last modified facet parameter, which specifies the lower bound of the date range.

See Also:
Constant Field Values

TO_FACET_PARAM_NAME

public static final String TO_FACET_PARAM_NAME
The name for the last modified facet parameter, which specifies the upper bound of the date range.

See Also:
Constant Field Values
Constructor Detail

Search

public Search(org.apache.sling.api.SlingHttpServletRequest request)
Creates a new search based on the given request.

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 no query parameter set.
Throws:
RepositoryException - if an exception occurs while executing the query.

getRelatedQueries

public List<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 String getQuery()
Returns:
the query supplied by the user or an empty String if none is provided.

setQuery

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

Parameters:
query - the fulltext query.

getExcerptPropertyNames

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

setExcerptPropertyNames

public void setExcerptPropertyNames(String properties)
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 String getSearchIn()
Returns:
the location where to search in.

setSearchIn

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

getSearchProperties

public String getSearchProperties()
Returns:
the names of the properties that will be searched.

setSearchProperties

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

appendConstraints

protected void appendConstraints(StringBuffer stmt,
                                 String relPath,
                                 String[] values)
Appends value constraints for the property with the given relPath.

Parameters:
stmt - the query statement.
relPath - the relative path to a property.
values - the values, or null if no constraints.


Copyright © 2008 Day Management AG. All Rights Reserved.