DataStax Enterprise 4.0

Inserting/updating data using the Solr HTTP API

To update indexed data in Solr and in the Cassandra table, use a URL in the following format to update the document:
curl http://host:port/solr/keyspace.table/update?
  replacefields=false  -H 'Content-type: application/json' -d
  'json string'

Updates to a CQL-backed Solr core replace the entire row. The deprecated replacefields parameter for inserting into, modifying, or deleting data from CQL Solr cores is not supported.

Procedure

Building on the collections example, insert data into the mykeyspace.mytable data and Solr index.
Use this curl command might look like this:
$ curl http://localhost:8983/solr/mykeyspace.mysolr/update?replacefields=false -H 'Content-type: application/json' -d '[{"id":"130", "body":"Life is a beach.", "name":"unknown", "title":"Life"}]'

The Solr convention is to use curl for issuing update commands instead of using a browser. You do not have to post a commit command in the update command as you do in OSS, and doing so is ineffective.

When you use CQL or CLI to update a field, DSE Search implicitly sets replacefields to false and updates individual fields in the Solr document. The re-indexing of data occurs automatically.

Warning about using the optimize command

Do not include the optimize command in URLs to update Solr data. This warning appears in the system log when you use the optimize:
WARN [http-8983-2] 2013-03-26 14:33:04,450 CassandraDirectUpdateHandler2.java (line 697)
Calling commit with optimize is not recommended.

The Lucene merge policy is very efficient. Using the optimize command is no longer necessary and using the optimize command in a URL can cause nodes to fail.

Show/hide