org.apache.solr.client.solrj.request

## Class UpdateRequest

- java.lang.Object
- - org.apache.solr.client.solrj.SolrRequest<UpdateResponse>
  - - org.apache.solr.client.solrj.request.AbstractUpdateRequest
    - - org.apache.solr.client.solrj.request.UpdateRequest

All Implemented Interfaces:
  Serializable, IsUpdateRequest

    public class UpdateRequest
    extends AbstractUpdateRequest

Since:
  solr 1.3
See Also:
  Serialized Form

### Nested Class Summary

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

`AbstractUpdateRequest.ACTION`

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

`SolrRequest.METHOD`

### Field Summary

Fields
`static String` `COMMIT_WITHIN`
`static String` `MIN_REPFACT` Deprecated. Solr now always includes in the response the `REPFACT`, this parameter doesn't need to be explicitly set
`static String` `OVERWRITE`
`static String` `REPFACT`
`static String` `VER`

### Fields inherited from class org.apache.solr.client.solrj.request.AbstractUpdateRequest

`commitWithin, params`

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

`SUPPORTED_METHODS, useBinaryV2, usev2`

### Constructor Summary

Constructors
Constructor and Description
`UpdateRequest()`
`UpdateRequest(String url)`

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`UpdateRequest` `add(Collection<SolrInputDocument> docs)` Add a collection of SolrInputDocuments to this request
`UpdateRequest` `add(SolrInputDocument doc)` Add a SolrInputDocument to this request
`UpdateRequest` `add(SolrInputDocument doc, Boolean overwrite)` Add a SolrInputDocument to this request
`UpdateRequest` `add(SolrInputDocument doc, Integer commitWithin)` Add a SolrInputDocument to this request
`UpdateRequest` `add(SolrInputDocument doc, Integer commitWithin, Boolean overwrite)` Add a SolrInputDocument to this request
`UpdateRequest` `add(String... fields)`
`void` `clear()` clear the pending documents and delete commands
`UpdateResponse` `commit(SolrClient client, String collection)`
`UpdateRequest` `deleteById(List<String> ids)`
`UpdateRequest` `deleteById(String id)`
`UpdateRequest` `deleteById(String id, Long version)`
`UpdateRequest` `deleteById(String id, String route)`
`UpdateRequest` `deleteById(String id, String route, Long version)`
`UpdateRequest` `deleteByQuery(String q)`
`Collection<ContentStream>` `getContentStreams()`
`List<String>` `getDeleteById()`
`Map<String,Map<String,Object>>` `getDeleteByIdMap()`
`List<String>` `getDeleteQuery()`
`Iterator<SolrInputDocument>` `getDocIterator()`
`List<SolrInputDocument>` `getDocuments()`
`Map<SolrInputDocument,Map<String,Object>>` `getDocumentsMap()`
`Map<String,LBHttpSolrClient.Req>` `getRoutes(DocRouter router, DocCollection col, Map<String,List<String>> urlMap, ModifiableSolrParams params, String idField)` Deprecated. since 8.0, uses `getRoutesToCollection(DocRouter, DocCollection, Map, ModifiableSolrParams, String)` instead
`Map<String,LBSolrClient.Req>` `getRoutesToCollection(DocRouter router, DocCollection col, Map<String,List<String>> urlMap, ModifiableSolrParams params, String idField)`
`String` `getXML()`
`boolean` `isLastDocInBatch()`
`void` `lastDocInBatch()`
`void` `setDeleteQuery(List<String> deleteQuery)`
`void` `setDocIterator(Iterator<SolrInputDocument> docIterator)`
`UpdateRequest` `withRoute(String route)`
`UpdateRequest` `writeXML(Writer writer)`

### Methods inherited from class org.apache.solr.client.solrj.request.AbstractUpdateRequest

`createResponse, getAction, getCommitWithin, getParams, isWaitSearcher, rollback, setAction, setAction, setAction, setAction, setAction, setAction, setAction, setCommitWithin, setParam, setParams, setWaitSearcher`

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

`addHeader, getBasePath, getBasicAuthPassword, getBasicAuthUser, getCollection, getContentWriter, getHeaders, getMethod, getPath, getQueryParams, getResponseParser, getStreamingResponseCallback, getUserPrincipal, process, process, setBasePath, setBasicAuthCredentials, setMethod, setPath, setQueryParams, setResponseParser, setStreamingResponseCallback, setUseBinaryV2, setUserPrincipal, setUseV2`

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

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

### Field Detail

#### REPFACT

    public static final String REPFACT

See Also:
  Constant Field Values

#### MIN_REPFACT

    public static final String MIN_REPFACT

Deprecated. Solr now always includes in the response the `REPFACT`, this parameter doesn't need to be explicitly set

See Also:
  Constant Field Values

#### VER

    public static final String VER

See Also:
  Constant Field Values

#### OVERWRITE

    public static final String OVERWRITE

See Also:
  Constant Field Values

#### COMMIT_WITHIN

    public static final String COMMIT_WITHIN

See Also:
  Constant Field Values

### Constructor Detail

#### UpdateRequest

    public UpdateRequest()

#### UpdateRequest

    public UpdateRequest(String url)

### Method Detail

#### clear

    public void clear()

clear the pending documents and delete commands

#### add

    public UpdateRequest add(SolrInputDocument doc)

Add a SolrInputDocument to this request

Throws:
  `NullPointerException` - if the document is null

#### add

    public UpdateRequest add(String... fields)

#### add

    public UpdateRequest add(SolrInputDocument doc,
                             Boolean overwrite)

Add a SolrInputDocument to this request

Parameters:
  `doc` - the document
  `overwrite` - true if the document should overwrite existing docs with the same id
Throws:
  `NullPointerException` - if the document is null

#### add

    public UpdateRequest add(SolrInputDocument doc,
                             Integer commitWithin)

Add a SolrInputDocument to this request

Parameters:
  `doc` - the document
  `commitWithin` - the time horizon by which the document should be committed (in ms)
Throws:
  `NullPointerException` - if the document is null

#### add

    public UpdateRequest add(SolrInputDocument doc,
                             Integer commitWithin,
                             Boolean overwrite)

Add a SolrInputDocument to this request

Parameters:
  `doc` - the document
  `commitWithin` - the time horizon by which the document should be committed (in ms)
  `overwrite` - true if the document should overwrite existing docs with the same id
Throws:
  `NullPointerException` - if the document is null

#### add

    public UpdateRequest add(Collection<SolrInputDocument> docs)

Add a collection of SolrInputDocuments to this request

Throws:
  `NullPointerException` - if any of the documents in the collection are null

#### deleteById

    public UpdateRequest deleteById(String id)

#### deleteById

    public UpdateRequest deleteById(String id,
                                    String route)

#### deleteById

    public UpdateRequest deleteById(String id,
                                    String route,
                                    Long version)

#### deleteById

    public UpdateRequest deleteById(List<String> ids)

#### deleteById

    public UpdateRequest deleteById(String id,
                                    Long version)

#### deleteByQuery

    public UpdateRequest deleteByQuery(String q)

#### withRoute

    public UpdateRequest withRoute(String route)

#### commit

    public UpdateResponse commit(SolrClient client,
                                 String collection)
                          throws IOException,
                                 SolrServerException

Throws:
  `IOException`
  `SolrServerException`

#### getRoutesToCollection

    public Map<String,LBSolrClient.Req> getRoutesToCollection(DocRouter router,
                                                              DocCollection col,
                                                              Map<String,List<String>> urlMap,
                                                              ModifiableSolrParams params,
                                                              String idField)

Parameters:
  `router` - to route updates with
  `col` - DocCollection for the updates
  `urlMap` - of the cluster
  `params` - params to use
  `idField` - the id field
Returns:
  a Map of urls to requests

#### getRoutes

    @Deprecated
    public Map<String,LBHttpSolrClient.Req> getRoutes(DocRouter router,
                                                                  DocCollection col,
                                                                  Map<String,List<String>> urlMap,
                                                                  ModifiableSolrParams params,
                                                                  String idField)

Deprecated. since 8.0, uses `getRoutesToCollection(DocRouter, DocCollection, Map, ModifiableSolrParams, String)` instead

Parameters:
  `router` - to route updates with
  `col` - DocCollection for the updates
  `urlMap` - of the cluster
  `params` - params to use
  `idField` - the id field
Returns:
  a Map of urls to requests

#### setDocIterator

    public void setDocIterator(Iterator<SolrInputDocument> docIterator)

#### setDeleteQuery

    public void setDeleteQuery(List<String> deleteQuery)

#### getContentStreams

    public Collection<ContentStream> getContentStreams()
                                                throws IOException

Overrides:
  `getContentStreams` in class `SolrRequest<UpdateResponse>`
Throws:
  `IOException`

#### getXML

    public String getXML()
                  throws IOException

Throws:
  `IOException`

#### writeXML

    public UpdateRequest writeXML(Writer writer)
                           throws IOException

Throws:
  `IOException`
Since:
  solr 1.4

#### getDocuments

    public List<SolrInputDocument> getDocuments()

#### getDocumentsMap

    public Map<SolrInputDocument,Map<String,Object>> getDocumentsMap()

#### getDocIterator

    public Iterator<SolrInputDocument> getDocIterator()

#### getDeleteById

    public List<String> getDeleteById()

#### getDeleteByIdMap

    public Map<String,Map<String,Object>> getDeleteByIdMap()

#### getDeleteQuery

    public List<String> getDeleteQuery()

#### isLastDocInBatch

    public boolean isLastDocInBatch()

#### lastDocInBatch

    public void lastDocInBatch()