データ・インジェストWebサービスでは、実行中のデータ・ドメインのレコードを置換できます。
ingestChangesのupdateRecords操作には、レコードを置換するreplaceRecords要素があります。
レコードを置換する場合、データ・インジェストWebサービスでは、最初にレコード(およびそのすべての属性のすべての割当て)を削除してから、指定された属性割当て(主キー属性の必須割当てを含む)を保持する新規レコードを追加します。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.endeca.com/MDEX/ingest/2/0" xmlns:ns1="http://www.endeca.com/MDEX/XQuery/2009/09"> <soapenv:Header/> <soapenv:Body> <ns:ingestChanges> <ns:replaceRecords> <ns:recordSpecifier>?</ns:recordSpecifier> <ns:record> <ns1:attribute name="?" type="mdex:string">?</ns1:attribute> </ns:record> </ns:replaceRecords> </ns:ingestChanges> </soapenv:Body> </soapenv:Envelope>
レコードの置換は削除と追加の組合せなので、削除対象のレコードを変更する操作と同じリクエストに含めることはできません。同様に、追加されるレコードは、同じリクエストの他の操作には使用できません。
外部トランザクションを開始するトランザクションWebサービスのリクエストの後に、ingestChangesリクエストを送信する場合、そのリクエストでは外部トランザクションIDを指定する必要があります。外部トランザクションが開始されていない場合、リクエストのID属性は省略する必要があります。
データ・ドメインのレコードを置換するには、次の手順を実行します。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.endeca.com/MDEX/ingest/2/0" xmlns:ns1="http://www.endeca.com/MDEX/XQuery/2009/09"> <soapenv:Header/> <soapenv:Body> <ns:ingestChanges> <ns:replaceRecords> <ns:recordSpecifier>"partID" = 'P345'</ns:recordSpecifier> <ns:record> <ns1:attribute name="partID">P345</ns1:attribute> <ns1:attribute name="color" type="mdex:string">green</ns1:attribute> <ns1:attribute name="price">100</ns1:attribute> </ns:record> </ns:replaceRecords> </ns:ingestChanges> </soapenv:Body> </soapenv:Envelope>
<ingest:ingestChangesResponse xmlns:ingest="http://www.endeca.com/MDEX/ingest/2/0"> <ingest:numPropertiesCreated>0</ingest:numPropertiesCreated> <ingest:numRecordsAffected>1</ingest:numRecordsAffected> <ingest:numRecordsDeleted>1</ingest:numRecordsDeleted> </ingest:ingestChangesResponse>
レコードが正しく識別されなくてもreplaceRecordsリクエストが失敗することはありませんが、(前の例では)レコードが1件も削除されずに、1つのレコードが追加されます。この場合、レスポンスのnumRecordsDeleted要素は値が0になり、numRecordsAffectedの値は1になります。