Azure Cosmos DB では、コンテナーごとに定義されたインデックス作成ポリシーに従ってデータのインデックスが作成されます。 新しく作成したコンテナーの既定のインデックス作成ポリシーでは、文字列または数値に範囲インデックスが適用されます。 このポリシーは、独自のカスタム インデックス作成ポリシーでオーバーライドできます。
注意書き
この記事で説明するインデックス作成ポリシーの更新方法は、Azure Cosmos DB for NoSQL にのみ適用されます。 「Azure Cosmos DB for MongoDB」と「Azure Cosmos DB for Apache Cassandra でのセカンダリ インデックス作成」でインデックス作成について学習します。
インデックス作成ポリシーの例
JSON 形式で示されたインデックス作成ポリシーの例をいくつか以下に示します。 これらは JSON 形式で Azure portal で公開されます。 Azure CLI または任意の SDK を使用して、同じパラメーターを設定できます。
一部のプロパティ パスを選択的に除外するオプトアウト ポリシー
{
"indexingMode": "consistent",
"includedPaths": [
{
"path": "/*"
}
],
"excludedPaths": [
{
"path": "/path/to/single/excluded/property/?"
},
{
"path": "/path/to/root/of/multiple/excluded/properties/*"
}
]
}
注意書き
- パーティション キーは (
/idされていない限り) インデックスが作成されないため、インデックスに含める必要があります。 - cosmos アカウントのインデックス作成モードが
idされると、システム プロパティ_tsとconsistentは常にインデックスが作成されます。 - システム プロパティ
idと_tsは、コンテナー ポリシーのインデックス付きパスの説明には含まれません。 これは、これらのシステム プロパティは既定でインデックスが作成され、この動作を無効にできないためです。
一部のプロパティ パスを選択的に包含するオプトイン ポリシー
{
"indexingMode": "consistent",
"includedPaths": [
{
"path": "/path/to/included/property/?"
},
{
"path": "/path/to/root/of/multiple/included/properties/*"
}
],
"excludedPaths": [
{
"path": "/*"
}
]
}
注意書き
一般に、''オプトアウト'' インデックス作成ポリシーを使用することをお勧めします。 Azure Cosmos DB では事前に、データ モデルに追加される可能性がある新しいプロパティのインデックスが作成されます。
特定のプロパティ パスでのみ空間インデックスを使用する
{
"indexingMode": "consistent",
"automatic": true,
"includedPaths": [
{
"path": "/*"
}
],
"excludedPaths": [
{
"path": "/_etag/?"
}
],
"spatialIndexes": [
{
"path": "/path/to/geojson/property/?",
"types": [
"Point",
"Polygon",
"MultiPolygon",
"LineString"
]
}
]
}
ベクトル インデックス作成ポリシーの例
個々のプロパティのパスを含めたり除外したりするほかに、ベクトル インデックスを指定することもできます。 一般に、クエリ ベクトルとベクトル プロパティの類似度を測定するために VectorDistance システム関数が使われているときは常に、ベクトル インデックスを指定する必要があります。
注意書き
先に進む前に、 Azure Cosmos DB NoSQL ベクターのインデックス作成と検索を有効にする必要があります。
重要
ベクトル インデックス作成ポリシーは、コンテナーのベクトル ポリシーで定義されている同じパス上に存在する必要があります。 詳細については、「 コンテナー ベクター ポリシー」を参照してください。
{
"indexingMode": "consistent",
"automatic": true,
"includedPaths": [
{
"path": "/*"
}
],
"excludedPaths": [
{
"path": "/_etag/?"
}
],
"vectorIndexes": [
{
"path": "/vector",
"type": "quantizedFlat"
}
]
}
重要
ワイルドカード文字 (*、 []) と配列内に入れ子になったベクター パスは、現在、ベクター ポリシーまたはベクター インデックスではサポートされていません。
重要
現在、ベクトル ポリシーとベクトル インデックスは、作成後に変更できません。 変更するには、新しいコレクションを作成します。
次の種類のベクトル インデックス ポリシーを定義できます。
| タイプ | 説明 | 最大ディメンション |
|---|---|---|
flat |
他のインデックス プロパティと同じインデックスにベクトルを格納します。 | 505 |
quantizedFlat |
インデックスに格納する前にベクトルを量子化 (圧縮) します。 これにより、わずかな精度を犠牲にして、待機時間とスループットを向上させることができます。 | 4096 |
diskANN |
高速かつ効率的な概算検索のために、DiskANN に基づいてインデックスを作成します。 | 4096 |
flatとquantizedFlatのインデックスの種類では、Azure Cosmos DB のインデックスを使用して、ベクター検索を実行するときに各ベクターを格納および読み取ります。
flat インデックスを使用するベクトル検索はブルート フォース検索であり、100% の精度を実現します。 ただし、フラット インデックスのベクターには 505 次元の制限があります。
quantizedFlat インデックスは、量子化つまり圧縮されたベクトルをインデックスに格納します。
quantizedFlat インデックスを使用したベクトル検索もブルート フォース検索ですが、インデックスに追加する前にベクトルが量子化されるため、精度は 100% をわずかに下回る可能性があります。 ただし、quantized flat を使用したベクトル検索は flat インデックスでのベクトル検索よりも待機時間が短く、スループットが高く、RU コストが低くなります。 これは、クエリ フィルターを使用してベクター検索を比較的小さなベクター セットに絞り込むシナリオに適したオプションです。
diskANN インデックスは、特に DiskANN を使用するベクター用に定義された別個のインデックスです。これは、Microsoft Research によって開発された高度にパフォーマンスの高いベクター インデックス作成アルゴリズムのスイートです。 DiskANN インデックスでは、待機時間が最も短く、1 秒あたりのクエリ数が最も高く (QPS)、RU コストが最も低いクエリの一部を高い精度で提供できます。 ただし、DiskANN は近似ニアレスト ネイバー (ANN) インデックスであるため、精度は quantizedFlat や flat よりも低くなる可能性があります。
diskANNインデックスとquantizedFlatインデックスは、すべての ANN ベクター インデックスに適用される精度と待機時間のトレードオフを調整するために使用できる、オプションのインデックス ビルド パラメーターを受け取ることができます。
-
quantizationByteSize: 製品量子化のサイズ (バイト単位) を設定します。Min=1、Default=dynamic (システムが決定)、Max=512。 この値を大きくすると、RU コストが高くなり、待機時間が長くなるという犠牲を伴って、ベクター検索の精度が高くなる可能性があります。 これは、quantizedFlatとDiskANNの両方のインデックスの種類に適用されます。 -
indexingSearchListSize: インデックスの構築中に検索するベクターの数を設定します。Min=10、Default=100、Max=500。 この値を大きく設定すると、インデックスのビルド時間が長くなり、ベクターの取り込みの待機時間が長くなるという犠牲を伴って、ベクター検索の精度が高くなる可能性があります。 これは、DiskANNインデックスにのみ適用されます。
シャード化された DiskANN の使用
シャード DiskANN は、DiskANN インデックスをより小さく管理しやすい部分に分割することで、大規模なベクター検索を最適化するのに役立ちます。 コンテナーのインデックス作成ポリシーで VectorIndexShardKey を指定すると、選択したドキュメント プロパティの一意の値ごとに 1 つずつ、複数の DiskANN インデックスを作成できます。
この方法により、クエリのパフォーマンスが向上し、再現率が向上し、RU コストが削減される可能性があります(特にカーディナリティの高いデータを操作する場合)。 推奨エンジン、セマンティック検索、インテリジェント エージェントのいずれを構築する場合でも、シャード化 DiskANN を使用すると、ベクター インデックス作成の構造と実行方法をより詳細に制御できます。
ここでは、tenantID プロパティに基づいてシャード キーを定義する例を示します。 これには、パーティション キーであっても、データ項目の任意のプロパティを指定できます。 1 つの文字列を配列で囲む必要があります。 詳細については、「 シャード化された DiskANN: 優先ベクター検索」を参照してください。
"vectorIndexes": [
{
"path": "/vector2",
"type": "DiskANN",
"vectorIndexShardKey": ["/tenantID"]
}
]
タプル インデックス作成ポリシーの例
このインデックス作成ポリシーの例では、 events.name と events.categoryにタプル インデックスを定義します。
{
"automatic":true,
"indexingMode":"Consistent",
"includedPaths":[
{"path":"/*"},
{"path":"/https/learn.microsoft.com/events/[]/{name,category}/?"}
],
"excludedPaths":[],
"compositeIndexes":[]
}
上記のインデックスは、次のクエリに使用されます。
SELECT *
FROM root r
WHERE
EXISTS (SELECT VALUE 1 FROM ev IN r.events
WHERE ev.name = 'M&M' AND ev.category = 'Candy')
複合インデックス作成ポリシーの例
個々のプロパティのパスを含めたり除外したりするほかに、複合インデックスを指定することもできます。 複数のプロパティに対して 1 つの ORDER BY 句を使用するクエリを実行するには、これらのプロパティに対する複合インデックスが必要になります。 クエリに複数のプロパティの並べ替えと共にフィルターが含まれている場合は、複数の複合インデックスが必要になることがあります。
複合インデックスには、複数のフィルターや、1 つのフィルターと 1 つの ORDER BY 句の両方があるクエリでパフォーマンス上の利点もあります。
注意書き
複合パスではスカラー値のインデックスのみが作成されるため、そのパスには /? が暗黙的に含まれています。 複合パスでは、 /* ワイルドカードはサポートされていません。 複合パスに /? または /* を指定しないでください。 また、複合パスでは大文字と小文字が区別されます。
(name asc, age desc) に対して定義された複合インデックス
{
"automatic":true,
"indexingMode":"Consistent",
"includedPaths":[
{
"path":"/*"
}
],
"excludedPaths":[],
"compositeIndexes":[
[
{
"path":"/https/learn.microsoft.com/name",
"order":"ascending"
},
{
"path":"/https/learn.microsoft.com/age",
"order":"descending"
}
]
]
}
次のクエリでは、名前と年齢の複合インデックスが必要です。
クエリ #1:
SELECT *
FROM c
ORDER BY c.name ASC, c.age DESC
クエリ #2:
SELECT *
FROM c
ORDER BY c.name DESC, c.age ASC
この複合インデックスでは、次のクエリで利点が得られ、フィルターが最適化されます。
クエリ #3:
SELECT *
FROM c
WHERE c.name = "Tim"
ORDER BY c.name DESC, c.age ASC
クエリ #4:
SELECT *
FROM c
WHERE c.name = "Tim" AND c.age > 18
(name ASC, age ASC) と (name ASC, age DESC) に対して複合インデックスが定義されている。
同じインデックス作成ポリシー内で複数の複合インデックスを定義できます。
{
"automatic":true,
"indexingMode":"Consistent",
"includedPaths":[
{
"path":"/*"
}
],
"excludedPaths":[],
"compositeIndexes":[
[
{
"path":"/https/learn.microsoft.com/name",
"order":"ascending"
},
{
"path":"/https/learn.microsoft.com/age",
"order":"ascending"
}
],
[
{
"path":"/https/learn.microsoft.com/name",
"order":"ascending"
},
{
"path":"/https/learn.microsoft.com/age",
"order":"descending"
}
]
]
}
(name ASC, age ASC) に定義されている複合インデックス
順序の指定は任意です。 指定されていない場合、順序は昇順です。
{
"automatic":true,
"indexingMode":"Consistent",
"includedPaths":[
{
"path":"/*"
}
],
"excludedPaths":[],
"compositeIndexes":[
[
{
"path":"/https/learn.microsoft.com/name"
},
{
"path":"/https/learn.microsoft.com/age"
}
]
]
}
すべてのプロパティ パスを除外するが、インデックス作成はアクティブな状態を維持する
このポリシーは、 Time to Live (TTL) 機能はアクティブですが、Azure Cosmos DB を純粋なキー値ストアとして使用するために必要な他のインデックスがない場合に使用できます。
{
"indexingMode": "consistent",
"includedPaths": [],
"excludedPaths": [{
"path": "/*"
}]
}
インデックス作成なし
このポリシーによってインデックス作成がオフになります。
indexingMode が none に設定されている場合、コンテナーで TTL を設定することはできません。
{
"indexingMode": "none"
}
インデックス作成ポリシーの更新
Azure Cosmos DB では、インデックス作成ポリシーは次のいずれかの方法を使用して更新できます。
- Azure portal から
- Azure CLI の使用
- PowerShell の使用
- SDK のいずれかを使用する
インデックス作成ポリシーの更新により、インデックスの変換がトリガーされます。 この変換の進行状況は、SDK を使用して追跡することもできます。
注意書き
インデックス作成ポリシーを更新するときに、Azure Cosmos DB への書き込みは中断されません。 インデックスの変換の詳細を確認してください。
重要
インデックスの削除はすぐに有効になりますが、新しいインデックスの追加にはインデックス作成変換が必要になるため、しばらく時間がかかります。 あるインデックスを別のインデックスに置き換える場合 (たとえば、1 つのプロパティ インデックスを複合インデックスに置き換える場合)、まず新しいインデックスを追加してから、インデックス変換 が完了するのを 待ってから、インデックス作成ポリシーから前のインデックスを削除してください。 そうしないと、前のインデックスに対してクエリを実行する機能に悪影響が及び、前のインデックスを参照するアクティブなワークロードが中断される可能性があります。
Azure ポータルの使用
Azure Cosmos DB のコンテナーには、そのインデックス作成ポリシーが Azure portal で直接編集できる JSON ドキュメントとして格納されます。
Azure portal にサインインします。
新しい Azure Cosmos DB アカウントを作成するか、既存のアカウントを選びます。
[データ エクスプローラー] ウィンドウを開いて、操作の対象となるコンテナーを選択します。
[ 設定] を選択し、[ インデックス作成ポリシー] を選択します。
これらの例に示すように、インデックス作成ポリシーの JSON ドキュメントを変更します。
完了したら、 [保存] を選択します。
Azure CLI の使用
カスタム インデックス作成ポリシーを使用してコンテナーを作成する場合は、CLI を使用したカスタム インデックス作成ポリシーでのコンテナーの作成に関する説明を参照してください。
PowerShell の使用
カスタム インデックス作成ポリシーを使用してコンテナーを作成する場合は、PowerShell を使用したカスタム インデックス作成ポリシーでのコンテナーの作成に関する説明を参照してください。
.NET SDK を使用する
ContainerProperties の オブジェクトでは、IndexingPolicy を変更し、IndexingMode および IncludedPaths を追加または削除できる ExcludedPaths プロパティを公開しています。 詳細については、「 クイック スタート: Azure SDK for .NET で Azure Cosmos DB for NoSQL を使用する」を参照してください。
// Retrieve the container's details
ContainerResponse containerResponse = await client.GetContainer("database", "container").ReadContainerAsync();
// Set the indexing mode to consistent
containerResponse.Resource.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
// Add an included path
containerResponse.Resource.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/*" });
// Add an excluded path
containerResponse.Resource.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/name/*" });
// Add a spatial index
SpatialPath spatialPath = new SpatialPath
{
Path = "/locations/*"
};
spatialPath.SpatialTypes.Add(SpatialType.Point);
containerResponse.Resource.IndexingPolicy.SpatialIndexes.Add(spatialPath);
// Add a composite index
containerResponse.Resource.IndexingPolicy.CompositeIndexes.Add(new Collection<CompositePath> { new CompositePath() { Path = "/name", Order = CompositePathSortOrder.Ascending }, new CompositePath() { Path = "/age", Order = CompositePathSortOrder.Descending } });
// Update container with changes
await client.GetContainer("database", "container").ReplaceContainerAsync(containerResponse.Resource);
インデックス変換の進行状況を追跡するには、RequestOptions プロパティを PopulateQuotaInfo に設定する true オブジェクトを渡します。
x-ms-documentdb-collection-index-transformation-progress 応答ヘッダーから値を取得します。
// retrieve the container's details
ContainerResponse containerResponse = await client.GetContainer("database", "container").ReadContainerAsync(new ContainerRequestOptions { PopulateQuotaInfo = true });
// retrieve the index transformation progress from the result
long indexTransformationProgress = long.Parse(containerResponse.Headers["x-ms-documentdb-collection-index-transformation-progress"]);
新しいコンテナーの作成中にカスタム インデックス作成ポリシーを定義すると、SDK V3 fluent API によって、この定義を簡潔かつ効率的な方法で記述できます。
await client.GetDatabase("database").DefineContainer(name: "container", partitionKeyPath: "/myPartitionKey")
.WithIndexingPolicy()
.WithIncludedPaths()
.Path("/*")
.Attach()
.WithExcludedPaths()
.Path("/name/*")
.Attach()
.WithSpatialIndex()
.Path("/locations/*", SpatialType.Point)
.Attach()
.WithCompositeIndex()
.Path("/name", CompositePathSortOrder.Ascending)
.Path("/age", CompositePathSortOrder.Descending)
.Attach()
.Attach()
.CreateIfNotExistsAsync();
Java SDK の使用
DocumentCollection の オブジェクトでは、getIndexingPolicy() および setIndexingPolicy() メソッドを公開しています。 これらによって操作される IndexingPolicy オブジェクトを使用すると、インデックス作成モードを変更したり、対象のパスと対象外のパスを追加または削除したりすることができます。 詳細については、「 クイック スタート: Azure SDK for Java で Azure Cosmos DB for NoSQL を使用する」を参照してください。
// Retrieve the container's details
Observable<ResourceResponse<DocumentCollection>> containerResponse = client.readCollection(String.format("/dbs/%s/colls/%s", "database", "container"), null);
containerResponse.subscribe(result -> {
DocumentCollection container = result.getResource();
IndexingPolicy indexingPolicy = container.getIndexingPolicy();
// Set the indexing mode to consistent
indexingPolicy.setIndexingMode(IndexingMode.Consistent);
// Add an included path
Collection<IncludedPath> includedPaths = new ArrayList<>();
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
// Add an excluded path
Collection<ExcludedPath> excludedPaths = new ArrayList<>();
ExcludedPath excludedPath = new ExcludedPath();
excludedPath.setPath("/name/*");
excludedPaths.add(excludedPath);
indexingPolicy.setExcludedPaths(excludedPaths);
// Add a spatial index
Collection<SpatialSpec> spatialIndexes = new ArrayList<SpatialSpec>();
Collection<SpatialType> collectionOfSpatialTypes = new ArrayList<SpatialType>();
SpatialSpec spec = new SpatialSpec();
spec.setPath("/locations/*");
collectionOfSpatialTypes.add(SpatialType.Point);
spec.setSpatialTypes(collectionOfSpatialTypes);
spatialIndexes.add(spec);
indexingPolicy.setSpatialIndexes(spatialIndexes);
// Add a composite index
Collection<ArrayList<CompositePath>> compositeIndexes = new ArrayList<>();
ArrayList<CompositePath> compositePaths = new ArrayList<>();
CompositePath nameCompositePath = new CompositePath();
nameCompositePath.setPath("/name");
nameCompositePath.setOrder(CompositePathSortOrder.Ascending);
CompositePath ageCompositePath = new CompositePath();
ageCompositePath.setPath("/age");
ageCompositePath.setOrder(CompositePathSortOrder.Descending);
compositePaths.add(ageCompositePath);
compositePaths.add(nameCompositePath);
compositeIndexes.add(compositePaths);
indexingPolicy.setCompositeIndexes(compositeIndexes);
// Update the container with changes
client.replaceCollection(container, null);
});
コンテナーに対するインデックス変換の進行状況を追跡するには、クォータ情報の読み込みを要求する RequestOptions オブジェクトを渡します。
x-ms-documentdb-collection-index-transformation-progress 応答ヘッダーから値を取得します。
// set the RequestOptions object
RequestOptions requestOptions = new RequestOptions();
requestOptions.setPopulateQuotaInfo(true);
// retrieve the container's details
Observable<ResourceResponse<DocumentCollection>> containerResponse = client.readCollection(String.format("/dbs/%s/colls/%s", "database", "container"), requestOptions);
containerResponse.subscribe(result -> {
// retrieve the index transformation progress from the response headers
String indexTransformationProgress = result.getResponseHeaders().get("x-ms-documentdb-collection-index-transformation-progress");
});
Node.js SDK の使用
ContainerDefinition の インターフェイスでは indexingPolicy プロパティを公開しています。これを使用すると、indexingMode を変更したり、includedPaths や excludedPaths を追加または削除したりすることができます。 詳細については、「 クイック スタート: Azure SDK for Node.jsで Azure Cosmos DB for NoSQL を使用する 」を参照してください。
コンテナーの詳細を取得する:
const containerResponse = await client.database('database').container('container').read();
インデックス作成モードを同期に設定する:
containerResponse.body.indexingPolicy.indexingMode = "consistent";
空間インデックスを含む対象パスを追加する:
containerResponse.body.indexingPolicy.includedPaths.push({
includedPaths: [
{
path: "/age/*",
indexes: [
{
kind: cosmos.DocumentBase.IndexKind.Range,
dataType: cosmos.DocumentBase.DataType.String
},
{
kind: cosmos.DocumentBase.IndexKind.Range,
dataType: cosmos.DocumentBase.DataType.Number
}
]
},
{
path: "/locations/*",
indexes: [
{
kind: cosmos.DocumentBase.IndexKind.Spatial,
dataType: cosmos.DocumentBase.DataType.Point
}
]
}
]
});
対象外パスを追加する:
containerResponse.body.indexingPolicy.excludedPaths.push({ path: '/name/*' });
変更に従ってコンテナーを更新する:
const replaceResponse = await client.database('database').container('container').replace(containerResponse.body);
コンテナーに対するインデックス変換の進行状況を追跡するには、RequestOptions プロパティを populateQuotaInfo に設定する true オブジェクトを渡します。
x-ms-documentdb-collection-index-transformation-progress 応答ヘッダーから値を取得します。
// retrieve the container's details
const containerResponse = await client.database('database').container('container').read({
populateQuotaInfo: true
});
// retrieve the index transformation progress from the response headers
const indexTransformationProgress = replaceResponse.headers['x-ms-documentdb-collection-index-transformation-progress'];
複合インデックスを追加する:
console.log("create container with composite indexes");
const containerDefWithCompositeIndexes = {
id: "containerWithCompositeIndexingPolicy",
indexingPolicy: {
automatic: true,
indexingMode: IndexingMode.consistent,
includedPaths: [
{
path: "/*",
},
],
excludedPaths: [
{
path: '/"systemMetadata"/*',
},
],
compositeIndexes: [
[
{ path: "/field", order: "ascending" },
{ path: "/key", order: "ascending" },
],
],
},
};
const containerWithCompositeIndexes = (
await database.containers.create(containerDefWithCompositeIndexes)
).container;
Go SDK を使用する
IndexingPolicy 構造体は、コンテナーのインデックス作成ポリシーを定義します。 これは、新しいコンテナーを作成するとき、または既存のコンテナーを再構成するときに使用できます。
db, _ := client.NewDatabase("demodb")
pkDefinition := azcosmos.PartitionKeyDefinition{
Paths: []string{"/state"},
Kind: azcosmos.PartitionKeyKindHash,
}
indexingPolicy := &azcosmos.IndexingPolicy{
IndexingMode: azcosmos.IndexingModeConsistent,
// add an included path
IncludedPaths: []azcosmos.IncludedPath{
{Path: "/*"},
},
// add an excluded path
ExcludedPaths: []azcosmos.ExcludedPath{
{Path: "/address/*"},
},
// add composite indices
CompositeIndexes: [][]azcosmos.CompositeIndex{
{
{
Path: "/name",
Order: azcosmos.CompositeIndexAscending,
},
{
Path: "/age",
Order: azcosmos.CompositeIndexDescending,
},
},
}
db.CreateContainer(context.Background(), azcosmos.ContainerProperties{
ID: "demo_container",
PartitionKeyDefinition: pkDefinition,
IndexingPolicy: indexingPolicy,
}, nil)
Python SDK の使用
Python SDK V3 を使用する場合、コンテナーの構成はディクショナリとして管理されます。 このディクショナリから、インデックス作成ポリシーとそのすべての属性にアクセスすることができます。 詳細については、「 クイック スタート: Azure SDK for Python で Azure Cosmos DB for NoSQL を使用する」を参照してください。
コンテナーの詳細を取得する:
containerPath = 'dbs/database/colls/collection'
container = client.ReadContainer(containerPath)
インデックス作成モードを同期に設定する:
container['indexingPolicy']['indexingMode'] = 'consistent'
対象パスと空間インデックスと共にインデックス作成ポリシーを定義する:
container["indexingPolicy"] = {
"indexingMode":"consistent",
"spatialIndexes":[
{"path":"/https/learn.microsoft.com/location/*","types":["Point"]}
],
"includedPaths":[{"path":"/https/learn.microsoft.com/age/*","indexes":[]}],
"excludedPaths":[{"path":"/*"}]
}
対象外パスと共にインデックス作成ポリシーを定義する:
container["indexingPolicy"] = {
"indexingMode":"consistent",
"includedPaths":[{"path":"/*","indexes":[]}],
"excludedPaths":[{"path":"/https/learn.microsoft.com/name/*"}]
}
複合インデックスを追加する:
container['indexingPolicy']['compositeIndexes'] = [
[
{
"path": "/name",
"order": "ascending"
},
{
"path": "/age",
"order": "descending"
}
]
]
変更に従ってコンテナーを更新する:
response = client.ReplaceContainer(containerPath, container)