중요합니다
이 기능은 프리뷰 상태입니다.
Cosmos DB의 인덱싱은 데이터가 어떻게 진화하든 빠르고 유연한 쿼리 성능을 제공하도록 설계되었습니다. 이 가이드에서는 패브릭 포털 또는 Azure SDK를 사용하여 컨테이너에 대한 인덱싱 정책을 수정합니다.
필수 조건
기존 패브릭 용량
- 패브릭 용량이 없는 경우 Fabric 평가판을 시작합니다.
패브릭의 기존 Cosmos DB 데이터베이스
- 아직 없는 경우 Fabric에서 새 Cosmos DB 데이터베이스를 만듭니다.
데이터가 있는 기존 컨테이너
- 아직 없는 경우 샘플 데이터 컨테이너를 로드하는 것이 좋습니다.
- Python 3.12 이상
- Node.js 22 이상
- .NET SDK 9.0 이상
패브릭 포털을 사용하여 설정
먼저 패브릭 포털을 사용하여 컨테이너에 대한 인덱싱 정책을 설정합니다.
Fabric 포털(https://app.fabric.microsoft.com)을 엽니다.
기존 Cosmos DB 데이터베이스로 이동합니다.
기존 컨테이너를 선택하고 확장합니다. 그런 다음 설정을 선택합니다.
설정 섹션에서 인덱싱 정책 탭을 선택합니다.
편집기에서 설정을 새 값으로 업데이트합니다. 예를 들어, 이 정책을 사용하여 컨테이너의 항목 중
name
및category
속성만 인덱싱하도록 인덱싱 정책을 설정할 수 있습니다.{ "indexingMode": "consistent", "automatic": true, "includedPaths": [ { "path": "/name/?" }, { "path": "/category/?" } ], "excludedPaths": [ { "path": "/*" } ] }
Azure SDK를 사용하여 설정
마지막으로 Azure SDK를 사용하여 컨테이너에 대한 인덱싱 정책을 설정합니다.
database = client.get_database_client("<database-name>")
container = database.get_container_client("<container-name>")
# Create policy that only indexes specific paths
indexing_policy = {
"indexingMode": "consistent",
"automatic": True,
"includedPaths": [
{
"path": "/name/?"
},
{
"path": "/category/?"
}
],
"excludedPaths": [
{
"path": "/*"
}
]
}
# Create policy that only indexes specific paths
database.replace_container(container, partition_key=PartitionKey(path='/<partition-key-path>'), indexing_policy=indexing_policy)
const container: Container = client.database('<database-name>').container('<container-name>');
const { resource: containerProperties } = await container.read();
// Create policy that only indexes specific paths
containerProperties['indexingPolicy'] = {
indexingMode: 'consistent',
automatic: true,
includedPaths: [
{
path: '/name/?'
},
{
path: '/category/?'
}
],
excludedPaths: [
{
path: '/*'
}
]
}
await container.replace(containerProperties);
Container container = client
.GetDatabase("<database-name>")
.GetContainer("<container-name>");
ContainerProperties properties = await container.ReadContainerAsync();
// Create policy that only indexes specific paths
IndexingPolicy indexingPolicy = new()
{
IndexingMode = IndexingMode.Consistent,
Automatic = true
};
indexingPolicy.ExcludedPaths.Add(
new ExcludedPath{ Path = "/*" }
);
indexingPolicy.IncludedPaths.Add(
new IncludedPath { Path = "/name/?" }
);
indexingPolicy.IncludedPaths.Add(
new IncludedPath { Path = "/category/?" }
);
properties.IndexingPolicy = indexingPolicy;
await container.ReplaceContainerAsync(properties);