|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.day.cq.search.impl.builder.QueryImpl
public class QueryImpl
QueryImpl implements the Query interface.
Its implementation builds the SearchResult and hold various
references to things such as the ResourceResolver. For managing the
predicates and building the XPath expression that is executed, it relies on a
simple RootEvaluator, which is an extended PredicateGroupEvaluator
that is able create a complete XPath expression (and not only the
[@x = y ...] predicateEvaluator part).
| Constructor Summary | |
|---|---|
QueryImpl(PredicateGroup rootPredicate,
Session session,
QueryBuilderImpl queryBuilder)
|
|
| Method Summary | |
|---|---|
protected SearchResultImpl |
execute()
|
Map<String,Facet> |
extractFacets()
|
boolean |
getExcerpt()
Returns whether the query will return plain nodes or an excerpt. |
Set<String> |
getExcerptPropertyNames()
|
String |
getFilteringPredicates()
|
long |
getHitsPerPage()
|
PredicateEvaluator |
getPredicateEvaluator(String type)
Can only be called during the execution of getResult(), because
it requires a cleanup done by calling
releasePredicateEvaluators(), which happens at the end of
getResult(). |
PredicateGroup |
getPredicates()
Returns the list of predicates that define this query. |
QueryResult |
getRawQueryResult()
|
org.apache.sling.api.resource.ResourceResolver |
getResourceResolver()
|
SearchResult |
getResult()
Executes the query and returns the result. |
Session |
getSession()
|
long |
getStart()
|
String |
getStatement()
|
Query |
refine(Bucket bucket)
This will return a new query that includes the given bucket from a previous search. |
void |
registerPredicateEvaluator(String type,
PredicateEvaluator evaluator)
This is an alternate way of providing a custom evaluator for predicates. |
void |
setExcerpt(boolean excerpt)
Whether the query should return plain nodes or an excerpt. |
void |
setHitsPerPage(long hitsPerPage)
Sets the number of hits to display on a ResultPage. |
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 |
|---|
public QueryImpl(PredicateGroup rootPredicate,
Session session,
QueryBuilderImpl queryBuilder)
| Method Detail |
|---|
public SearchResult getResult()
QueryQuery only runs once. This also
means that adding or
removing predicates is no
longer possible after calling getResult().
getResult in interface Querypublic PredicateGroup getPredicates()
QueryQuery.getResult() has been
called.
getPredicates in interface Query
public void registerPredicateEvaluator(String type,
PredicateEvaluator evaluator)
QueryPredicateEvaluator), but in some cases it is simpler to inline
them, for example to provide a custom facet extraction inside a JSP. A
notable difference is that this mechanism is only valid for the current
Query, whereas the OSGi component way of registration makes the
evaluator available for all queries.
To register, a type must be specified. This evaluator will
be used for all predicates with that type. Evaluators registered this way
will have precedence over evaluators provided as OSGi component
factories.
registerPredicateEvaluator in interface Querytype - the predicate type to register the evaluator forevaluator - a custom predicate evaluatorpublic Query refine(Bucket bucket)
QueryBucket.getPredicate()) and add it to the new query so that both
the existing predicate group is required and this new predicate
are required to match.
refine in interface Querybucket - a bucket (typically from the facets of this queries search
result)
public void setExcerpt(boolean excerpt)
Queryfalse.
setExcerpt in interface Queryexcerpt - true if an excerpt should be returned,
false if notpublic boolean getExcerpt()
Queryfalse.
getExcerpt in interface Querytrue if an excerpt should be returned,
false if notpublic long getStart()
getStart in interface Querypublic void setStart(long start)
Querystart) items of the underlying result. By default
this is 0, ie. right from the very beginning.
setStart in interface Querystart - the offset in the actual search results to start frompublic long getHitsPerPage()
getHitsPerPage in interface Querypublic void setHitsPerPage(long hitsPerPage)
QueryResultPage. For unlimited
results on a single page, use 0. Default value is 10
setHitsPerPage in interface QueryhitsPerPage - the number of hits to display on a page (0 for all).public Session getSession()
public org.apache.sling.api.resource.ResourceResolver getResourceResolver()
public PredicateEvaluator getPredicateEvaluator(String type)
getResult(), because
it requires a cleanup done by calling
releasePredicateEvaluators(), which happens at the end of
getResult().
public Set<String> getExcerptPropertyNames()
public QueryResult getRawQueryResult()
public Map<String,Facet> extractFacets()
public String getStatement()
public String getFilteringPredicates()
protected SearchResultImpl execute()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||