Package org.apache.solr.client.solrj.request

# Class GenericSolrRequest

java.lang.Object
org.apache.solr.client.solrj.SolrRequest<SimpleSolrResponse>
org.apache.solr.client.solrj.request.GenericSolrRequest

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `GenericV2SolrRequest`

public class GenericSolrRequest extends SolrRequest<SimpleSolrResponse>

See Also:
  - Serialized Form

## Nested Class Summary

## Nested classes/interfaces inherited from class org.apache.solr.client.solrj.SolrRequest

`SolrRequest.ApiVersion, SolrRequest.METHOD, SolrRequest.SolrClientContext, SolrRequest.SolrRequestType`

## Field Summary

Fields
Modifier and Type
Field
Description
`RequestWriter.ContentWriter`
`contentWriter`
`boolean`
`requiresCollection`
`SimpleSolrResponse`
`response`

### Fields inherited from class org.apache.solr.client.solrj.SolrRequest

`SUPPORTED_METHODS`

## Constructor Summary

Constructors
Constructor
Description
`GenericSolrRequest(SolrRequest.METHOD m, String path)`
`GenericSolrRequest(SolrRequest.METHOD m, String path, SolrRequest.SolrRequestType requestType)`
`GenericSolrRequest(SolrRequest.METHOD m, String path, SolrRequest.SolrRequestType requestType, SolrParams params)`
`GenericSolrRequest(SolrRequest.METHOD m, String path, SolrParams params)`

## Method Summary

Modifier and Type
Method
Description
`protected SimpleSolrResponse`
`createResponse(NamedList<Object> namedList)`
Create a new SolrResponse to hold the response from the server.
`RequestWriter.ContentWriter`
`getContentWriter(String expectedType)`
If a request object wants to do a push write, implement this method.
`SolrParams`
`getParams()`
The parameters for this request; never null.
`boolean`
`requiresCollection()`
Determines whether this request should use or ignore any specified collections (esp.
`GenericSolrRequest`
`setContentWriter(RequestWriter.ContentWriter contentWriter)`
`GenericSolrRequest`
`setRequiresCollection(boolean requiresCollection)`
Determines whether the SolrRequest should use a default collection or core from the client
`GenericSolrRequest`
`withContent(byte[] buf, String type)`

### Methods inherited from class org.apache.solr.client.solrj.SolrRequest

`addHeader, addHeaders, getApiVersion, getBasicAuthPassword, getBasicAuthUser, getCollection, getContentStreams, getHeaders, getMethod, getPath, getPreferredNodes, getQueryParams, getRequestType, getResponseParser, getStreamingResponseCallback, getUserPrincipal, process, process, processWithBaseUrl, setBasicAuthCredentials, setMethod, setPath, setPreferredNodes, setQueryParams, setRequestType, setResponseParser, setStreamingResponseCallback, setUserPrincipal`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### response

public SimpleSolrResponse response

### contentWriter

public RequestWriter.ContentWriter contentWriter

### requiresCollection

public boolean requiresCollection

## Constructor Details

### GenericSolrRequest

public GenericSolrRequest(SolrRequest.METHOD m, String path)

Parameters:
  `m` - the HTTP method to use for this request
  `path` - the HTTP path to use for this request. If users are making a collection-aware request (i.e. `setRequiresCollection(boolean)` is called with 'true'), only the section of the API path following the collection or core should be provided here.

### GenericSolrRequest

public GenericSolrRequest(SolrRequest.METHOD m, String path, SolrRequest.SolrRequestType requestType)

Parameters:
  `m` - the HTTP method to use for this request
  `path` - the HTTP path to use for this request. If users are making a collection-aware request (i.e. `setRequiresCollection(boolean)` is called with 'true'), only the section of the API path following the collection or core should be provided here.
  `requestType` - the type of this request

### GenericSolrRequest

public GenericSolrRequest(SolrRequest.METHOD m, String path, SolrParams params)

Parameters:
  `m` - the HTTP method to use for this request
  `path` - the HTTP path to use for this request. If users are making a collection-aware request (i.e. `setRequiresCollection(boolean)` is called with 'true'), only the section of the API path following the collection or core should be provided here.
  `params` - query parameter names and values for making this request.

### GenericSolrRequest

public GenericSolrRequest(SolrRequest.METHOD m, String path, SolrRequest.SolrRequestType requestType, SolrParams params)

Parameters:
  `m` - the HTTP method to use for this request
  `path` - the HTTP path to use for this request. If users are making a collection-aware request (i.e. `setRequiresCollection(boolean)` is called with 'true'), only the section of the API path following the collection or core should be provided here.
  `requestType` - the type of this request
  `params` - query parameter names and values for making this request.

## Method Details

### setRequiresCollection

public GenericSolrRequest setRequiresCollection(boolean requiresCollection)
Determines whether the SolrRequest should use a default collection or core from the client

Should generally be 'true' whenever making a request to a particular collection or core, and 'false' otherwise.

Parameters:
  `requiresCollection` - true if a default collection should be used, false otherwise.

### requiresCollection

public boolean requiresCollection()
Description copied from class: `SolrRequest`
Determines whether this request should use or ignore any specified collections (esp. `SolrClient.defaultCollection`)

Many Solr requests target a particular core or collection. But not all of them - many Solr APIs (e.g. security or other admin APIs) are agnostic of collections entirely. This method gives these requests a way to opt out of using `SolrClient.defaultCollection` or other specified collections.

Overrides:
  `requiresCollection` in class `SolrRequest<SimpleSolrResponse>`

### setContentWriter

public GenericSolrRequest setContentWriter(RequestWriter.ContentWriter contentWriter)

### withContent

public GenericSolrRequest withContent(byte[] buf, String type)

### getContentWriter

public RequestWriter.ContentWriter getContentWriter(String expectedType)
Description copied from class: `SolrRequest`
If a request object wants to do a push write, implement this method.

Overrides:
  `getContentWriter` in class `SolrRequest<SimpleSolrResponse>`
Parameters:
  `expectedType` - This is the type that the RequestWriter would like to get. But, it is OK to send any format

### getParams

public SolrParams getParams()
Description copied from class: `SolrRequest`
The parameters for this request; never null. The runtime type may be mutable but modifications may not affect this `SolrRequest` instance, as it may return a new instance here every time. If the subclass specifies the response type as `ModifiableSolrParams`, then one can expect it to change this request. If the subclass has a setter then one can expect this method to return the value set.

Specified by:
  `getParams` in class `SolrRequest<SimpleSolrResponse>`

### createResponse

protected SimpleSolrResponse createResponse(NamedList<Object> namedList)
Description copied from class: `SolrRequest`
Create a new SolrResponse to hold the response from the server. If the response extends `SolrResponse`, then there's no need to use the arguments, as `SolrResponse.setResponse(NamedList)` will be called right after this method.

Specified by:
  `createResponse` in class `SolrRequest<SimpleSolrResponse>`
Parameters:
  `namedList` - from `SolrClient.request(SolrRequest, String)`.