SolrQueryResponse (Solr 3.6.2 API)
Keywords: org.apache.solr.response.SolrQueryResponse class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.solr.response
Class SolrQueryResponse

    java.lang.Object
      org.apache.solr.response.SolrQueryResponse

Direct Known Subclasses:
  SolrQueryResponse

    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 list
- `NamedList` containing any of the items in this list
- `Collection` containing any of the items in this list
- Array containing any of the items in this list
- null

Other data types may be added to the SolrQueryResponse, but there is no guarantee that QueryResponseWriters will be able to deal with unexpected types.

Since:
  solr 0.9
Version:
  $Id: SolrQueryResponse.java 898152 2010-01-12 02:19:56Z ryan $

Field Summary
`protected Set<String>` | `defaultReturnFields`
`protected long` | `endtime` The endtime of the request in milliseconds.
`protected Exception` | `err`
`protected boolean` | `httpCaching` Should this response be tagged with HTTP caching headers?
`protected NamedList` | `toLog` Container for storing information that should be logged by Solr before returning.
`protected NamedList` | `values` Container for user defined values

Constructor Summary
`SolrQueryResponse()` // another way of returning an error int errCode; String errMsg;

Method Summary
`void` | `add(String name, Object val)` Appends a named value to the list of named values to be returned.
`void` | `addToLog(String name, Object val)` Add a value to be logged.
`long` | `getEndTime()` Get the time in milliseconds when the response officially finished.
`Exception` | `getException()` Returns an Exception if there was a fatal error in processing the request.
`NamedList` | `getResponseHeader()` Repsonse header to be logged
`Set<String>` | `getReturnFields()` Gets the document field names of fields to return by default when returning DocLists
`NamedList` | `getToLog()` Get loggable items.
`NamedList` | `getValues()` Gets data to be returned in this response
`boolean` | `isHttpCaching()` Should this response emit HTTP caching headers?
`void` | `setAllValues(NamedList nameValuePairs)` Sets data to be returned in this response
`long` | `setEndTime()` Stop the timer for how long this query took.
`long` | `setEndTime(long endtime)` Set the in milliseconds when the response officially finished.
`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` | `setReturnFields(Set<String> fields)` Sets the document field names of fields to return by default when returning DocLists

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### values

    protected NamedList values

  Container for user defined values

  See Also:
    `getValues()`, `add(java.lang.String, java.lang.Object)`, `setAllValues(org.apache.solr.common.util.NamedList)`, Note on Returnable Data

### toLog

    protected NamedList toLog

  Container for storing information that should be logged by Solr before returning.

### defaultReturnFields

    protected Set<String> defaultReturnFields

### err

    protected Exception err

### httpCaching

    protected boolean httpCaching

  Should this response be tagged with HTTP caching headers?

### endtime

    protected long endtime

  The endtime of the request in milliseconds. Used to calculate query time.

  See Also:
    `setEndTime(long)`, `getEndTime()`

Constructor Detail

### SolrQueryResponse

    public SolrQueryResponse()

  // another way of returning an error int errCode; String errMsg;

Method Detail

### getValues

    public NamedList getValues()

  Gets data to be returned in this response

  See Also:
    Note on Returnable Data

### setAllValues

    public void setAllValues(NamedList nameValuePairs)

  Sets data to be returned in this response

  See Also:
    Note on Returnable Data

### setReturnFields

    public void setReturnFields(Set<String> fields)

  Sets the document field names of fields to return by default when returning DocLists

### getReturnFields

    public Set<String> getReturnFields()

  Gets the document field names of fields to return by default when returning DocLists

### add

    public void add(String name,
                    Object val)

  Appends a named value to the list of named values to be returned.

  Parameters:
    `name` - the name of the value - may be null if unnamed
    `val` - the value to add - also may be null since null is a legal value
  See Also:
    Note on Returnable Data

### setException

    public void setException(Exception e)

  Causes an error to be returned instead of the results.

### getException

    public Exception getException()

  Returns an Exception if there was a fatal error in processing the request. Returns null if the request succeeded.

### getEndTime

    public long getEndTime()

  Get the time in milliseconds when the response officially finished.

### setEndTime

    public long setEndTime()

  Stop the timer for how long this query took.

  See Also:
    `setEndTime(long)`

### setEndTime

    public long setEndTime(long endtime)

  Set the in milliseconds when the response officially finished.

  See Also:
    `setEndTime()`

### getResponseHeader

    public NamedList getResponseHeader()

  Repsonse header to be logged

### addToLog

    public void addToLog(String name,
                         Object val)

  Add a value to be logged.

  Parameters:
    `name` - name of the thing to log
    `val` - value of the thing to log

### getToLog

    public NamedList getToLog()

  Get loggable items.

  Returns:
    things to log

### setHttpCaching

    public void setHttpCaching(boolean httpCaching)

  Enables or disables the emission of HTTP caching headers for this response.

  Parameters:
    `httpCaching` - true=emit caching headers, false otherwise

### isHttpCaching

    public boolean isHttpCaching()

  Should this response emit HTTP caching headers?

  Returns:
    true=yes emit headers, false otherwise

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD