Package com.day.cq.search.writer
Interface ResultHitWriter
- All Known Implementing Classes:
FullNodeHitWriter,SelectivePropHitWriter,SimpleHitWriter
public interface ResultHitWriter
ResultHitWriter writes a search result
Hit into a
JSONWriter. This is used in the standard servlet for the query
builder to allow different output renderings. The appropriate
ResultHitWriter is selected by passing the desired name in the query
using p.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 a ResultHitWriter 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
Modifier and TypeMethodDescriptionvoidwrite(Hit hit, JSONWriter writer, Query query) Writes a givenHitinto theJSONWriter.
-
Method Details
-
write
Writes a givenHitinto 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
-