Package com.day.cq.search.writer
Interface ResultHitWriter
-
- All Known Implementing Classes:
FullNodeHitWriter
,SelectivePropHitWriter
,SimpleHitWriter
public interface ResultHitWriter
ResultHitWriter writes a search resultHit
into aJSONWriter
. This is used in the standard servlet for the query builder to allow different output renderings. The appropriateResultHitWriter
is selected by passing the desired name in the query usingp.hitwriter=NAME
as request parameter.Implementations of this interface must be defined as an OSGi component factory. The name of the factory must be the fully qualified name of this interface plus "/" and a distinct short name of the renderer (that will be used in request parameters to select it,
NAME
above). For example for aResultHitWriter
under the name "damasset", the SCR annotation would look like this:@Component(factory="com.day.cq.search.result.ResultHitWriter/damasset")
- Since:
- 5.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
write(Hit hit, JSONWriter writer, Query query)
Writes a givenHit
into theJSONWriter
.
-
-
-
Method Detail
-
write
void write(Hit hit, JSONWriter writer, Query query) throws RepositoryException, JSONException
Writes a givenHit
into theJSONWriter
. This will be called for each hit of the result page. The surrounding json structure is an array and each entry should be a simple object. The caller will have invoked thewriter.object()
already and will callwriter.endObject()
directly after this method returns.- Parameters:
hit
- the result hit to renderwriter
- to output jsonquery
- the original query; can be used to access custom parameters set in the predicate root group (query.getPredicates().get("param", "default")
)- Throws:
RepositoryException
- in case access on the hit failedJSONException
- in case there is a problem with writing to the jsonwriter
-
-