コレクションの作成操作

SConfig Webサービスには、コレクションを作成する2つの操作があります。

putCollection操作は単一のコレクションを作成するのに対し、putCollections操作は一度に複数のコレクションを作成できます。どちらの操作でも、Dgraphでコレクション定義レコード(CDR)が作成されます。

putCollectionの構文

putCollection操作では、次の構文を使用してコレクションを1つ作成します。
<putCollection>
   <outerTransactionId>?</outerTransactionId>
   <language>en</language>
   <collection collectionKey="?" displayName="?" uniquePropertyKey="?">
      <description>?</description>
      <property key="?">?</property>
   </collection>
</putCollection>
コレクションの属性の意味は次のとおりです。
コレクションの属性 説明
collectionKey 必須です。コレクションの一意の識別子。キー名はNCName書式である必要はありませんが、コレクション名の間で一意である必要があります。他のコレクション操作または問合せで使用する際、この名前では大文字と小文字が区別されます。
displayName オプションです。Studioなどのフロントエンド・アプリケーションで使用できる表示名を定義します。表示名には任意の文字列を使用できます。
uniquePropertyKey 必須です。コレクション内にあるレコードの一意のキー値を提供する標準属性を設定します。コレクションに対して構成したuniquePropertyKeyは、他のコレクションには使用できません。また、この標準属性はすでにレコードに割り当てられたものではない必要があります。
この標準属性のPDRは、次のように作成する必要があります。
  • mdex-property_IsSingleAssigntrueに設定
  • mdex-property_IsUniquetrueに設定

この標準属性は、このコレクション内にあるレコードの主キー(レコード仕様)としても機能することに注意してください。

description オプションです。コレクションに関する説明テキストを提供します。
property key オプションです。コレクションの文字列メタデータ・プロパティ(たとえば、ロケール情報)を関連付けることができます。キー名はNCName書式である必要があります。

putCollectionの例

次のputCollection soapUIの例では、Productsという名前のコレクションを作成します。
<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:putCollection>
         <ns:language>en</ns:language>
         <ns:collection collectionKey="Products" displayName="Product data" uniquePropertyKey="ProductID">
            <ns:description>product records for the region</ns:description>
            <ns:property key="Region">New England</ns:property>
         </ns:collection>
      </ns:putCollection>
   </soapenv:Body>
</soapenv:Envelope>

既存のProductID標準属性は、コレクションの一意のプロパティ・キーとして使用されます。コレクションには、Regionプロパティ・メタデータをNew England地域として定義するメタデータも関連付けられています。

putCollections操作

putCollections操作では、次の構文を使用して一度に複数のコレクションを作成できます。
<putCollections>
   <outerTransactionId>?</outerTransactionId>
   <language>en</language>
   <collection collectionKey="?" displayName="?" uniquePropertyKey="?">
      <description>?</description>
      <property key="?">?</property>
   </collection>
</putCollections>

単一処理用のputCollection操作と同じ構文と意味を持つ、複数のcollection要素を指定できます。

putCollectionResponse

正常なputCollections操作のレスポンスは、次の例のようになります。
<putCollectionResponse xmlns="http://www.endeca.com/endeca-server/sconfig/3/0">
   <collectionAdditionInformation numCollectionsAdded="1" numCollectionsReplaced="0"/>
</putCollectionResponse>

このレスポンスは、新しいコレクションが1つ追加されたことを示しています。