コレクションとそのレコードの削除

この手順では、最初にコレクションのレコードを削除してからコレクション自体を削除する方法について説明します。

次の手順では、soapUIを使用して様々なAPIコールを行います。ただし、同じアクションを実行するIntegrator ETLグラフを作成できます。

次の手順では、コレクション・レコードの実際の削除は、データ・インジェストWebサービスのdeleteRecords操作によって実行されます。
<ingestChanges>
   <deleteRecords>
      <recordSpecifier>ResellerKey IS NOT NULL</recordSpecifier>
   </deleteRecords>
</ingestChanges>

recordSpecifier要素のEQL文は、コレクション内のレコード用のフィルタとしてコレクションの一意のプロパティ・キーを使用します。つまり、この一意のプロパティ・キーに対してNULL以外の割当てを持つすべてのレコードが、削除対象として選択されます。

コレクションのレコードを削除してからコレクション自体を削除する手順:

  1. listCollections操作を使用して、コレクションの一意のプロパティ・キーの名前を取得します。

    次のサンプル・レスポンスでは、ResellerKey属性が、削除するResellersコレクションの一意のプロパティ・キーです。

    <collectionRecord collectionKey="Resellers" displayName="reseller data" uniquePropertyKey="ResellerKey">
  2. オプションで、次の例のようにトランザクションWebサービスのstartOuterTransaction操作を使用して、削除操作のための外部トランザクションを開始できます。
    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>
    成功した場合、レスポンスは次の例のようになります。
    <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. コレクションの一意のプロパティ・キーを使用して、ingestChangesdeleteRecords操作を実行します。
    <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>
    削除操作が成功した場合、レスポンスは次のようになります。
    <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. deleteCollections操作を使用して、コレクションを削除します。
    <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>
    deleteCollections操作が成功した場合、レスポンスは次のようになります。
    <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. deleteFilterRules操作を使用して、削除されたコレクションを参照するフィルタ・ルールを削除します。
    <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>
    フィルタ・ルールの削除操作が成功した場合、レスポンスは次のようになります。
    <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. 削除操作のための外部トランザクションを開始した場合は、トランザクションWebサービスのcommitOuterTransaction操作を使用して次のトランザクションをコミットします。
    <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>
    コミットが成功した場合、レスポンスは次のようになります。
    <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>

この手順ではレコード属性のPDRは削除されないことに注意してください。PDRはあまりメモリーを消費しないため、Dgraph内に残しておくと後でコレクションを再構築する場合にソース・レコードを再収集しやすくなります。それでも、必要に応じて検索インタフェースおよび属性グループをチェックし、使用しなくなった属性を削除してください。