Package org.apache.solr.response
Interface QueryResponseWriter
- All Superinterfaces:
NamedListInitializedPlugin
- All Known Subinterfaces:
TextQueryResponseWriter
- All Known Implementing Classes:
CborResponseWriter,CSVResponseWriter,GeoJSONResponseWriter,GraphMLResponseWriter,JacksonJsonWriter,JavaBinResponseWriter,JSONResponseWriter,PrometheusResponseWriter,RawResponseWriter,SchemaXmlResponseWriter,SmileResponseWriter,XMLResponseWriter
Used to format responses to the client (not necessarily a "query").
Different QueryResponseWriters are registered with the SolrCore. One
way to register a QueryResponseWriter with the core is through the solrconfig.xml
file.
Example solrconfig.xml entry to register a QueryResponseWriter
implementation to handle all queries with a writer type of "simple":
<queryResponseWriter name="simple" class="foo.SimpleResponseWriter" />
A single instance of any registered QueryResponseWriter is created via the default constructor and is reused for all relevant queries.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetContentType(SolrQueryRequest request, SolrQueryResponse response) Return the applicable Content Type for a request, this method must be thread safe.default voidwrite(OutputStream out, SolrQueryRequest request, SolrQueryResponse response) voidwrite(OutputStream out, SolrQueryRequest request, SolrQueryResponse response, String contentType) Writes the response to theOutputStream.default StringwriteToString(SolrQueryRequest request, SolrQueryResponse response) Writes a String for debugging / testing purposes.Methods inherited from interface org.apache.solr.util.plugin.NamedListInitializedPlugin
init
-
Field Details
-
CONTENT_TYPE_XML_UTF8
- See Also:
-
CONTENT_TYPE_TEXT_UTF8
- See Also:
-
-
Method Details
-
write
void write(OutputStream out, SolrQueryRequest request, SolrQueryResponse response, String contentType) throws IOException Writes the response to theOutputStream.contentTypeis fromgetContentType(SolrQueryRequest, SolrQueryResponse), and it's often ignored.- Throws:
IOException
-
write
default void write(OutputStream out, SolrQueryRequest request, SolrQueryResponse response) throws IOException - Throws:
IOException
-
getContentType
Return the applicable Content Type for a request, this method must be thread safe.QueryResponseWriter's must implement this method to return a valid HTTP Content-Type header for the request, that will logically correspond with the output produced by the write method.
- Returns:
- a Content-Type string, which may not be null.
-
writeToString
default String writeToString(SolrQueryRequest request, SolrQueryResponse response) throws IOException Writes a String for debugging / testing purposes.- Throws:
IOException
-