public interface ResultHitWriter
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")
Modifier and Type | Method and Description |
---|---|
void |
write(Hit hit,
JSONWriter writer,
Query query)
Writes a given
Hit into the JSONWriter . |
void write(Hit hit, JSONWriter writer, Query query) throws RepositoryException, JSONException
Hit
into the JSONWriter
. 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 the writer.object()
already and will call
writer.endObject()
directly after this method returns.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")
)RepositoryException
- in case access on the hit failedJSONException
- in case there is a problem with writing to the jsonwriterCopyright © 2010 - 2020 Adobe. All Rights Reserved