Replacing record assignments

You can update records in a running data domain by replacing standard attribute and managed value assignments.

The updateRecords sub-operation of ingestChanges includes the replaceAssignments element that replaces assignments from records in the data domain.

This element replaces standard attribute assignments as well as managed value assignments. Similar to record replacement, if there are no assignments already in the data domain that match the new assignments, the assignment is still added.

Assignment replacement cannot be combined with any other operation that would modify the assignments to be replaced.

The updateRecords operation allows you to have only one recordSpecifier element. This element is expected to contain an EQL expression identifying one or more records. Therefore, if you combine more than one updating element inside an updateRecords operation, it is worth remembering that all updating operations (additions, deletions, and replacements) will run only on records identified by the EQL expression inside recordSpecifier.

Because the Dgraph process of the Oracle Endeca Server performs type-checking when adding standard attributes, keep the following in mind:
  • When adding a value for a pre-existing standard attribute, make sure that the new value is of the proper type. An error will occur for type mismatches (for example, if you attempt to assign the string "red" to an integer standard attribute).
  • When creating and adding a new standard attribute, you should specify the attribute type.
  • Any standard attribute that is not specifically typed will be treated by default as a string type.

If an attribute is multi-select and has more than one assignment value on some of the records, the replaceAssignments element deletes all of these assignments and adds the one assignment that you specify.

The replaceAssignments request can also rename an attribute in your data domain. For information, see Changing the name of a standard attribute.

Important: Do not to use replaceAssignments to modify the system-created attributes in the data domain. For example, do not use it to set the system mdex-property_IsSingleAssign property to false for all attributes. Doing so may have some undesired effect on your application, such as not being able to create views correctly in Studio.

If you submit the ingestChanges request after a Transaction Web Service request that starts an 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.

replaceAssignments request

The replaceAssignments element of the updateRecords sub-operation removes individual standard attribute and/or managed value assignments from the specified records in your data domain, and replaces them with new assignment values. You can replace one or more assignments in the same request.

To replace individual assignments:
  • Indicate which records should be affected by including the EQL filter inside the recordSpecifier element in your request.
  • Specify the attributes for which assignment values should be replaced for these records.
The replaceAssignments request format is:
<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:updateRecords>
            <ns:recordSpecifier>?</ns:recordSpecifier>
            <ns:replaceAssignments>
               <ns1:attribute name="?">?</ns1:attribute>
            </ns:replaceAssignments>
         </ns:updateRecords>
      </ns:ingestChanges>
   </soapenv:Body>
</soapenv:Envelope>
where the string that you add to a recordSpecifier element is an EQL expression identifying records.
The following example illustrates this request:
<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:updateRecords>
            <ns:recordSpecifier>"price" > 5</ns:recordSpecifier>
            <ns:replaceAssignments>
               <ns1:attribute name="color">black</ns1:attribute>
            </ns:replaceAssignments>
         </ns:updateRecords>
      </ns:ingestChanges>
   </soapenv:Body>
</soapenv:Envelope>

The example replaces all values of the color standard attribute assignment for all records whose values for the price attribute are higher than 5 with the value black.

A successful ingestChangesResponse returned from the above sample request should look like this:
<ingest:ingestChangesResponse xmlns:ingest="http://www.endeca.com/MDEX/ingest/3/0">
    <ingest:numPropertiesCreated>0</ingest:numPropertiesCreated>
    <ingest:numRecordsAffected>7</ingest:numRecordsAffected>
    <ingest:numRecordsDeleted>0</ingest:numRecordsDeleted>
</ingest:ingestChangesResponse>

The numRecordsAffected element in the response shows that seven records were successfully modified.