Delete by id

Delete by id deletes the document with a specified id and is more efficient than delete by query.

Delete by id deletes the document with a specified id and is more efficient than delete by query. The id is the value of the uniqueKey field declared in the schema. The id can be a synthetic id that represents a Cassandra compound primary key, such as the one used in the Solr tutorial. After running a simple search on the tutorial data, click Execute Query to list results. Each result includes a _uniqueKey in JSON format, as shown in step 3. In this example, ["47336", "29"] are the values of the id, age compound primary key. The following delete by id query shows the syntax of the HTTP API command to remove that particular record from the Solr index:

$ curl http://localhost:8983/solr/nhanes_ks.nhanes/update --data '<delete><id>["47336","29"]</id></delete>' -H 'Content-type:text/xml; charset=utf-8'

After deleting the record, run a simple search on the Solr tutorial data again. The Solr Admin shows that the number of documents has been reduced by one: 20049. Query the Cassandra table using cqlsh:

cqlsh:nhanes_ks> SELECT * FROM nhanes WHERE id=47336;

The cqlsh output also confirms that the data was removed. Null values appear instead of the data.