solrconfig.xml
":<requestParsers enableStreamBody="true" />
solrUrl
", "collectionName
", ...) with your information.id
" and "field1
" to your SchemaXml.openSearcher
" to true (SolrConfigXml file -> updateHandler -> autoCommit)stream.body
) using the request handler /update
:final String UPDATE_REQUEST_PATH = "/update"; final String[] solrUrl = { "http://localhost:8983/solr" }; final String collectionName = "collection1"; // org.apache.solr.common.params.CommonParams.STREAM_BODY = "stream.body"; // org.apache.solr.common.params.CollectionAdminParams.COLLECTION = "collection"; final CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder(Arrays.asList(solrUrl)).build(); cloudSolrClient.setDefaultCollection(collectionName); // updating documents [/update] [ModifiableSolrParams] [stream.body] { final String streamBody = "<add><doc><field name=\"id\">1</field><field name=\"dynamicField1_s\" update=\"set\">dynamicField1_s 1-1</field><field name=\"field1\" update=\"set\">field1 1-1</field></doc></add>"; final ModifiableSolrParams modifiableSolrParams = new ModifiableSolrParams(); modifiableSolrParams.add(CommonParams.STREAM_BODY, streamBody); modifiableSolrParams.add(CollectionAdminParams.COLLECTION, collectionName); final UpdateRequest updateRequest = new UpdateRequest(); updateRequest.setParams(modifiableSolrParams); updateRequest.setPath(UPDATE_REQUEST_PATH); updateRequest.setMethod(METHOD.POST); final NamedList<Object> response = cloudSolrClient.request(updateRequest); System.out.println(response); } cloudSolrClient.close();