Deleting records

The Data Ingest Web Service lets you delete records from a running data store.

You use the deleteRecords element in a request to delete a record. The request must specify the primary key of the record to be deleted, using this request format:
<ingest:ingestRecords>
   <ingest:deleteRecords>
      <mdex:record>
         <primaryKeyProp>keyValue</primaryKeyProp>
      </mdex:record>
   </ingest:deleteRecords>
</ingest:ingestRecords>

Multiple records can be deleted in the same request. Each record must be specified within an mdex:record element.

If you submit the ingestRecords request after a Transaction Web Service request that starts an outer transaction, the request must specify the outer transaction ID. If no outer transactions have been started, the ID attribute must be omitted in the request.

To delete a record from the data store:

  1. Make certain that both the data store's Dgraph process and the Data Ingest service are running.
  2. Create a deleteRecords request, similar to the example below that deletes two records, and send the request to the Data Ingest service.
    <ingest:ingestRecords>
       <ingest:deleteRecords>
          <mdex:record>
             <partID>PK-123</partID>
          </mdex:record>
          <mdex:record>
             <supplierID>SV-789</supplierID>
          </mdex:record>
       </ingest:deleteRecords>
    </ingest:ingestRecords>
  3. After the request is made, check the ingestRecordsResponse to determine if the request transaction was successful.
A successful ingestRecordsResponse returned from the above sample request should look like this:
<ingest:ingestRecordsResponse 
     xmlns:ingest="http://www.endeca.com/MDEX/ingest/1/0">
   <ingest:numPropertiesCreated>0</ingest:numPropertiesCreated>
   <ingest:numRecordsAffected>0</ingest:numRecordsAffected>
   <ingest:numRecordsDeleted>2</ingest:numRecordsDeleted>
</ingest:ingestRecordsResponse>
Note that when specifying an invalid or missing primary key record, the deleteRecords operation will not fail, but instead will ignore the record. In this case, the numRecordsDeleted element in the response will have a value of 0 (zero) and an entry (similar to the following example) is made in the Dgraph log:
Request: - fn:trace(, delete-records.xq: 
A record with specifier (partID = SV-352) does not exist.)