Adding primary-key attributes

Before you add a new record, a record must have a unique assignment from a primary-key attribute.

Adding a PDR for the primary-key attribute

When you add a new record with the Data Ingest Web Service, the service checks that the primary-key attribute already exists in the Endeca data domain. Therefore, if you have an empty data domain, before adding any records, you need to identify which attribute in your records is going to serve as the primary-key attribute, and add its PDR to the data domain.

The following example shows how to add a PDR for the primary-key attribute named partID. Notice that the mdex-property_IsUnique attribute for this PDR is set to true. This identifies the attribute partID as the primary-key attribute:
<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:addRecords>
   <ns:record>
    <ns1:attribute name="mdex-property_Key" type="mdex:string">partID</ns1:attribute>
    <ns1:attribute name="mdex-property_DisplayName" type="mdex:string">Part ID</ns1:attribute>
    <ns1:attribute name="mdex-property_Type" type="mdex:string">mdex:string</ns1:attribute>
    <ns1:attribute name="mdex-property_Language" type="mdex:string">en</ns1:attribute>
    <ns1:attribute name="mdex-property_IsSingleAssign" type="mdex:boolean">false</ns1:attribute>
    <ns1:attribute name="mdex-property_IsUnique" type="mdex:boolean">true</ns1:attribute>
    <ns1:attribute name="mdex-property_IsTextSearchable" type="mdex:boolean">false</ns1:attribute>
    <ns1:attribute name="mdex-property_TextSearchAllowsWildcards" type="mdex:boolean">
      false</ns1:attribute>
    <ns1:attribute name="mdex-property_IsPropertyValueSearchable" type="mdex:boolean">
      true</ns1:attribute>
    <ns1:attribute name="system-navigation_Select" type="mdex:string">single</ns1:attribute>
    <ns1:attribute name="system-navigation_Sorting" type="mdex:string">record-count</ns1:attribute>
    <ns1:attribute name="system-navigation_ShowRecordCounts" type="mdex:boolean">true</ns1:attribute>
    <ns1:attribute name="system-property_GroupMembership" type="mdex:string">
      system_properties</ns1:attribute>
   </ns:record>
  </ns:addRecords>
 </ns:ingestChanges>
</soapenv:Body>
</soapenv:Envelope>
Now that the primary-key attribute partID is created in the data domain, the following example shows how to create a new record whose assignment on the primary-key attribute will be partID=P123. This example uses the ingestChanges operation of the Data Ingest Web Service with the addRecords element:
<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:addRecords>
            <ns:record>
             <ns1:attribute name="partID" type="mdex:string">P123</ns1:attribute>
           </ns:record>
         </ns:addRecords>
       </ns:ingestChanges>
   </soapenv:Body>
</soapenv:Envelope>

Values for primary-key attributes

If you specify a non-existent attribute as the primary key, the standard attribute is automatically created by the Data Ingest Web Service.

The following table shows the settings you should use for the primary-key attribute. Except for mdex-property_IsUnique which must be set to true, all other attributes of the primary-key attribute can use the system default settings for PDRs. If you have not yet added records to the data domain, you can change all settings on the PDR for the primary-key attribute, except for the mdex-property_IsUnique which must be always set to true:
PDR property Default setting
mdex-property_Key Set to the name specified in the request.
mdex-property_Type Set to the Dgraph property type specified in the request. If no property type was specified, defaults to an mdex:string type.
mdex-property_Language Set to a supported language ID. Defaults to either unknown or to the language ID set by the Configuration Web Service's setPropertyDefaultLanguage operation.
mdex-property_IsPropertyValueSearchable true (the attribute is enabled for value search)
mdex-property_IsSingleAssign false (a record may have more than one value for the attribute)
mdex-property_IsTextSearchable false (the attribute is disabled for record search)
mdex-property_IsUnique true (a value may be assigned to at most one record)
mdex-property_TextSearchAllowsWildcards false (wildcard search is disabled for this attribute)
system-navigation_Select single (allows selecting only one refinement from this attribute)
system-navigation_ShowRecordCounts true (record counts are shown for a refinement)
system-navigation_Sorting record-count (refinements are sorted in descending order, by the number of records available for each refinement)