Deleting by id

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

Delete by id removes 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 Basic tutorial. To delete by id, the following example builds on the example in running a simple search. After clicking Execute Query, a list of results appears. Each result includes a _uniqueKey in JSON format. The uniqueKey is the first line of each result and looks like this:
<str name="_uniqueKey">["47336","29"]</str>
In this example, ["47336", "29"] are the values of the id, age compound primary key. The following delete by id query shows the HTTP API command you use 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. 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.