public class SolrQueryResponse extends Object
SolrQueryResponse
is used by a query handler to return
the response to a query request.
Note On Returnable Data...
A SolrQueryResponse
may contain the following types of
Objects generated by the SolrRequestHandler
that processed
the request.
String
Integer
Long
Float
Double
Boolean
Date
DocList
SolrDocument
(since 1.3)SolrDocumentList
(since 1.3)Map
containing any of the items in this listNamedList
containing any of the items in this listCollection
containing any of the items in this listOther data types may be added to the SolrQueryResponse, but there is no guarantee that QueryResponseWriters will be able to deal with unexpected types.
Modifier and Type | Field and Description |
---|---|
protected Exception |
err |
protected boolean |
httpCaching
Should this response be tagged with HTTP caching headers?
|
static String |
NAME |
static String |
RESPONSE_HEADER_PARTIAL_RESULTS_KEY |
static String |
RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY |
protected ReturnFields |
returnFields |
protected NamedList<Object> |
toLog
Container for storing information that should be logged by Solr before returning.
|
protected NamedList<Object> |
values
Container for user defined values
|
Constructor and Description |
---|
SolrQueryResponse()
// another way of returning an error
int errCode;
String errMsg;
|
Modifier and Type | Method and Description |
---|---|
void |
add(String name,
Object val)
Appends a named value to the list of named values to be returned.
|
void |
addHttpHeader(String name,
String value)
Adds a response header with the given name and value.
|
void |
addResponse(Object response)
Set response
|
void |
addResponseHeader(NamedList<Object> header)
Set response header
|
void |
addToLog(String name,
Object val)
Add a value to be logged.
|
Exception |
getException()
Returns an Exception if there was a fatal error in processing the request.
|
String |
getHttpHeader(String name)
Gets the value of the response header with the given name.
|
Collection<String> |
getHttpHeaders(String name)
Gets the values of the response header with the given name.
|
Object |
getResponse()
Return response
|
NamedList<Object> |
getResponseHeader()
Response header to be logged
|
ReturnFields |
getReturnFields()
Gets the document field names of fields to return by default when
returning DocLists
|
NamedList<Object> |
getToLog()
Get loggable items.
|
String |
getToLogAsString(String logid)
Returns a string of the form "logid name1=value1 name2=value2 ..."
|
NamedList |
getValues()
Gets data to be returned in this response
|
Iterator<Map.Entry<String,String>> |
httpHeaders()
Returns a new iterator of response headers
|
boolean |
isHttpCaching()
Should this response emit HTTP caching headers?
|
String |
removeHttpHeader(String name)
Removes a previously added header with the given name (only
the first one if multiple are present for the same name)
|
Collection<String> |
removeHttpHeaders(String name)
Removes all previously added headers with the given name.
|
void |
removeResponseHeader()
Clear response header
|
void |
setAllValues(NamedList<Object> nameValuePairs)
Sets data to be returned in this response
|
void |
setException(Exception e)
Causes an error to be returned instead of the results.
|
void |
setHttpCaching(boolean httpCaching)
Enables or disables the emission of HTTP caching headers for this response.
|
void |
setHttpHeader(String name,
String value)
Sets a response header with the given name and value.
|
void |
setReturnFields(ReturnFields fields)
Sets the document field names of fields to return by default when
returning DocLists
|
public static final String NAME
public static final String RESPONSE_HEADER_PARTIAL_RESULTS_KEY
public static final String RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY
protected NamedList<Object> toLog
protected ReturnFields returnFields
protected Exception err
protected boolean httpCaching
public SolrQueryResponse()
public NamedList getValues()
public void setAllValues(NamedList<Object> nameValuePairs)
public void setReturnFields(ReturnFields fields)
public ReturnFields getReturnFields()
public void add(String name, Object val)
name
- the name of the value - may be null if unnamedval
- the value to add - also may be null since null is a legal valuepublic void setException(Exception e)
public Exception getException()
public void removeResponseHeader()
public void addResponse(Object response)
public Object getResponse()
public void addToLog(String name, Object val)
name
- name of the thing to logval
- value of the thing to logpublic String getToLogAsString(String logid)
public void setHttpCaching(boolean httpCaching)
httpCaching
- true=emit caching headers, false otherwisepublic boolean isHttpCaching()
public void setHttpHeader(String name, String value)
name
- the name of the headervalue
- the header value If it contains octet string,
it should be encoded according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt)addHttpHeader(java.lang.String, java.lang.String)
,
HttpServletResponse.setHeader(java.lang.String, java.lang.String)
public void addHttpHeader(String name, String value)
name
- the name of the headervalue
- the additional header value If it contains
octet string, it should be encoded
according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt)setHttpHeader(java.lang.String, java.lang.String)
,
HttpServletResponse.addHeader(java.lang.String, java.lang.String)
public String getHttpHeader(String name)
If a response header with the given name exists and contains multiple values, the value that was added first will be returned.
NOTE: this runs in linear time (it scans starting at the beginning of the list until it finds the first pair with the specified name).
name
- the name of the response header whose value to returnpublic Collection<String> getHttpHeaders(String name)
name
- the name of the response header whose values to returnCollection
of the values
of the response header with the given namepublic String removeHttpHeader(String name)
NOTE: this runs in linear time (it scans starting at the beginning of the list until it finds the first pair with the specified name).
name
- the name of the response header to removepublic Collection<String> removeHttpHeaders(String name)
name
- the name of the response headers to removeCollection
with all the values
of the removed entries. It returns null
if no
entries are found for the given nameCopyright © 2000-2018 Apache Software Foundation. All Rights Reserved.