Deleting a collection and its records

This procedure describes how you first delete a collection's records and then delete the collection itself.

The procedure below uses soapUI to make the various API calls. However, you can create an Integrator ETL graph that performs the same actions.

In the procedure, the actual deletion of the collection records is performed by the deleteRecords operation of the Data Ingest Web Service:
<ingestChanges>
   <deleteRecords>
      <recordSpecifier>ResellerKey IS NOT NULL</recordSpecifier>
   </deleteRecords>
</ingestChanges>

The EQL statement for the recordSpecifier element will use the collection's unique property key as a filter for the records in the collection. That is, all records that have a non-NULL assignment for the unique property key will be selected for deletion.

To delete a collection's records and then the collection itself:

  1. Use the listCollections operation to obtain the name of the collection's unique property key.

    In this sample response, the ResellerKey attribute is the unique property key of the Resellers collection that is going to be deleted:

    <collectionRecord collectionKey="Resellers" displayName="reseller data" uniquePropertyKey="ResellerKey">
  2. Optionally, you can start an outer transaction for the delete operation, as in this example that uses the Transaction Web Service's startOuterTransaction operation:
    soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:ns="http://www.endeca.com/MDEX/transaction/1/0">
       <soapenv:Header/>
       <soapenv:Body>
          <ns:startOuterTransaction>
             <ns:OuterTransactionId>50</ns:OuterTransactionId>
          </ns:startOuterTransaction>
       </soapenv:Body>
    </soapenv:Envelope>
    If successful, the response should be similar to this example:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Header/>
       <soapenv:Body>
          <transaction:startOuterTransactionResponse xmlns:transaction="http://www.endeca.com/MDEX/transaction/1/0">
             <Started xmlns="http://www.endeca.com/MDEX/transaction/1/0">true</Started>
             <OuterTransactionId xmlns="http://www.endeca.com/MDEX/transaction/1/0">50</OuterTransactionId>
          </transaction:startOuterTransactionResponse>
       </soapenv:Body>
    </soapenv:Envelope>
  3. Run the deleteRecords operation of ingestChanges with the unique property key of the collection:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
         xmlns:ns="http://www.endeca.com/MDEX/ingest/3/0" 
         xmlns:ns1="http://www.endeca.com/MDEX/XQuery/2009/09">
       <soapenv:Header/>
       <soapenv:Body>
          <ns:ingestChanges>
             <ns:OuterTransactionId>50</ns:OuterTransactionId>
             <ns:Language>en</ns:Language>
             <ns:deleteRecords>
                <ns:recordSpecifier>ResellerKey IS NOT NULL</ns:recordSpecifier>
             </ns:deleteRecords>
          </ns:ingestChanges>
       </soapenv:Body>
    </soapenv:Envelope>
    If the delete operation was successful, the response should be similar to this:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Header/>
       <soapenv:Body>
          <ingest:ingestChangesResponse xmlns:ingest="http://www.endeca.com/MDEX/ingest/3/0">
             <ingest:numPropertiesCreated>0</ingest:numPropertiesCreated>
             <ingest:numRecordsAffected>0</ingest:numRecordsAffected>
             <ingest:numRecordsDeleted>334</ingest:numRecordsDeleted>
          </ingest:ingestChangesResponse>
       </soapenv:Body>
    </soapenv:Envelope>
  4. Use the deleteCollections operation to delete the collection.
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:ns="http://www.endeca.com/endeca-server/sconfig/3/0">
       <soapenv:Header/>
       <soapenv:Body>
          <ns:deleteCollections>
             <ns:outerTransactionId>50</ns:outerTransactionId>
             <ns:language>en</ns:language>
             <ns:collectionKey collectionKey="Resellers"/>
          </ns:deleteCollections>
       </soapenv:Body>
    </soapenv:Envelope>
    If the deleteCollections operation was successful, the response should look like this:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
       <env:Header/>
       <env:Body>
          <ns3:deleteCollectionsResponse xmlns:ns2="http://www.endeca.com/MDEX/eql_parser/types" 
                xmlns:ns3="http://www.endeca.com/endeca-server/sconfig/3/0">
             <ns3:numCollectionsDeleted>1</ns3:numCollectionsDeleted>
          </ns3:deleteCollectionsResponse>
       </env:Body>
    </env:Envelope>
  5. Use the deleteFilterRules operation to delete the filter rules that reference the now-deleted collection:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:ns="http://www.endeca.com/endeca-server/sconfig/3/0">
       <soapenv:Header/>
       <soapenv:Body>
          <ns:deleteFilterRules>
             <ns:outerTransactionId>50</ns:outerTransactionId>
             <ns:language>en</ns:language>
             <ns:filterRuleKey filterRuleKey="ResellerRule"/>
          </ns:deleteFilterRules>
       </soapenv:Body>
    </soapenv:Envelope>
    If the delete filter rule operation was successful, the response should look like this:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
       <env:Header/>
       <env:Body>
          <ns3:deleteFilterRulesResponse xmlns:ns2="http://www.endeca.com/MDEX/eql_parser/types" 
               xmlns:ns3="http://www.endeca.com/endeca-server/sconfig/3/0">
             <ns3:numFilterRulesDeleted>1</ns3:numFilterRulesDeleted>
          </ns3:deleteFilterRulesResponse>
       </env:Body>
    </env:Envelope>
  6. If you had started an outer transaction for the delete operation, use the Transaction Web Service's commitOuterTransaction operation to commit the transaction:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
         xmlns:ns="http://www.endeca.com/MDEX/transaction/1/0">
       <soapenv:Header/>
       <soapenv:Body>
          <ns:commitOuterTransaction>
             <ns:OuterTransactionId>50</ns:OuterTransactionId>
          </ns:commitOuterTransaction>
       </soapenv:Body>
    </soapenv:Envelope>
    If the commit was successful, the response should look like this:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Header/>
       <soapenv:Body>
          <transaction:commitOuterTransactionResponse xmlns:transaction="http://www.endeca.com/MDEX/transaction/1/0">
             <Committed xmlns="http://www.endeca.com/MDEX/transaction/1/0">true</Committed>
             <OuterTransactionId xmlns="http://www.endeca.com/MDEX/transaction/1/0">50</OuterTransactionId>
          </transaction:commitOuterTransactionResponse>
       </soapenv:Body>
    </soapenv:Envelope>

Note that procedure does not delete the PDRs of the record attributes. The PDRs do not take up much memory, and having them in the Dgraph will make it easier to re-ingest the source records if you later decide to rebuild the collection. However, it is a good idea to check your search interfaces and attribute groups and remove any attributes that are no longer used.