ファセットベースのインデックス作成 - Amazon Cloud Directory

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

ファセットベースのインデックス作成

ファセットベースのインデックス作成と検索では、ディレクトリのサブセットのみを検索することで、ディレクトリの検索を最適化できます。これを行うには、スキーマファセットを使用します。たとえば、ディレクトリ内のすべてのユーザーオブジェクトを検索する代わりに、従業員ファセットを含むユーザーオブジェクトのみを検索できます。この効率化により、クエリで取得するデータのレイテンシー時間と量を低減できます。

ファセットベースのインデックス作成では、Cloud Directory インデックス API オペレーションを使用してインデックスを作成し、オブジェクトのファセットにアタッチできます。また、インデックス結果を表示し、これらの結果を特定のファセットに基づいてフィルタすることもできます。これにより、特定タイプのファセットを含むオブジェクトのみを検索範囲にして、クエリ時間を短縮し、データ量を削減できます。

“facets” API コールと CreateIndex API コールで使用される ListIndex 属性は、オブジェクトに適用されるファセットのコレクションを表面化させます。この属性は、CreateIndex API コールと ListIndex API コールでのみ使用できます。次のサンプルコードに示すように、スキーマ ARN はディレクトリのリージョン、所有者アカウント、およびディレクトリ ID を使用して Cloud Directory スキーマを参照します。このサービスが提供するスキーマは一覧に表示されません。

String cloudDirectorySchemaArn = String.format(“arn:aws:clouddirectory:%s:%s:directory/%s/schema/CloudDirectory/1.0", region, ownerAccount, directoryId);

たとえば、次のサンプルコードで作成される AWS アカウントおよびディレクトリに固有のファセットベースのインデックスでは、ファセット SalesDepartmentFacet で作成されるすべてのオブジェクトを列挙できます。

注記

以下に示すように、パラメータ内で「facets」値を必ず使用します。サンプルコードに示されている「facets」のインスタンスは、Cloud Directory サービスによって提供および制御される値を参照します。これらはインデックス作成に利用できますが、読み取り専用アクセスに限られます。

// Create a facet-based index String cloudDirectorySchemaArn = String.format(“arn:aws:clouddirectory:%s:%s:directory/%s/schema/CloudDirectory/1.0", region, ownerAccount, directoryId); facetIndexResult = clouddirectoryClient.createIndex(new CreateIndexRequest() .withDirectoryArn(directoryArn) .withOrderedIndexedAttributeList(List(new AttributeKey() .withSchemaArn(cloudDirectorySchemaArn) .withFacetName("facets") .withName("facets"))) .withIsUnique(false) .withParentReference("/") .withLinkName("MyFirstFacetIndex")) facetIndex = facetIndexResult.getObjectIdentifier() // Attach objects to the facet-based index clouddirectoryClient.attachToIndex(new AttachToIndexRequest().withDirectoryArn(directoryArn) .withIndexReference(facetIndex).withTargetReference(userObj)) // List all objects val listResults = clouddirectoryClient.listIndex(new ListIndexRequest() .withDirectoryArn(directoryArn) .withIndexReference(facetIndex) .getIndexAttachments() // List the index results filtering for a certain facet val filteredResults = clouddirectoryClient.listIndex(new ListIndexRequest() .withDirectoryArn(directoryArn) .withIndexReference(facetIndex) .withRangesOnIndexedValues(new ObjectAttributeRange() .withAttributeKey(new AttributeKey() .withFacetName("facets") .withName("facets") .withSchemaArn(cloudDirectorySchemaArn)) .withRange(new TypedAttributeValueRange() .withStartMode(RangeMode.INCLUSIVE) .withStartValue("MySchema/1.0/SalesDepartmentFacet") .withEndMode(RangeMode.INCLUSIVE) .withEndValue("MySchema/1.0/SalesDepartmentFacet") )))