Adding key-value assignments

Records in the data store can be updated with new assignments for standard attributes and managed values.

The ingestRecords operation, when used with the addAssignments element, lets you update existing records in the data store by adding standard attribute values and/or managed values. The element can also create a standard or managed attribute if the attribute to be added does not exist. In this case, it is added with the defaults listed in Default values for new attributes in the data store.

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 Dgraph process property type.
  • Any standard attribute that is not specifically typed will be treated by default as a string type.

You can assign multiple values from a given standard attribute only if the attribute is configured as a multi-assign standard attribute. That means that the PDR for the standard attribute has the mdex-property_IsSingleAssign property set to true. If the addAssignments list attempts to assign multiple values to a standard attribute that does not accept multiple values, an error is signaled.

Managed values can be added to records even if the managed attribute to which they belong does not exist in the data store. In this case, the Data Ingest Web Service automatically creates the managed attribute.

addAssignments request

You use the addAssignments element in a request to add key-value pairs to an existing record. The request must specify the primary key of the record to be updated, using this request format:
<ingest:ingestRecords 
      xmlns:ingest="http://www.endeca.com/MDEX/ingest/1/0" 
      xmlns:mdex="http://www.endeca.com/MDEX/XQuery/2009/09">
   <ingest:addAssignments>
      <mdex:record>
         <primaryKeyProp>keyValue</primaryKeyProp>
         <propToAdd>keyValue</propToAdd>
         <!-- Other property assignments -->
      </mdex:record>
   </ingest:ingest:addAssignments>
</ingest:ingestRecords>
For example, this request updates a record (with the primary key P123) with three standard attributes (color, price, and numInStock) and one managed value (the managed value with the managed value spec of 4 in the Style managed attribute):
<ingest:ingestRecords 
      xmlns:ingest="http://www.endeca.com/MDEX/ingest/1/0" 
      xmlns:mdex="http://www.endeca.com/MDEX/XQuery/2009/09">
   <ingest:addAssignments>
      <mdex:record>
         <partID>P123</partID>
         <color>yellow</color>
         <price>18.99</price>
         <numInStock type="mdex:int">10</numInStock>
         <Style>4</Style>
      </mdex:record>
   </ingest:addAssignments>
</ingest:ingestRecords>

Note that the Dgraph process property type of the numInStock standard attribute is specified, because the standard attribute does not exist and therefore will be created as part of the request. The other standard attributes and the Style managed attribute already exist in the data store.

Note: 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.