in AzureCosmosDB/csharp/DocumentVectorPipelineFunctions/CosmosDBClientWrapper.cs [112:152]
private async Task GetOrCreateDatabaseAndContainerAsync()
{
var dbResponse = await this.client.CreateDatabaseIfNotExistsAsync("semantic_search_db");
var indexingPolicy = new IndexingPolicy()
{
// TODO: Include Full-Text Index for the chunk_text property.
VectorIndexes =
[
new VectorIndexPath
{
Path = "/embedding",
Type = VectorIndexType.QuantizedFlat,
}
]
};
indexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/embedding/*" });
var containerResponse = await dbResponse.Database.CreateContainerIfNotExistsAsync(new ContainerProperties
{
Id = "doc_search_container",
PartitionKeyPath = "/document_url",
IndexingPolicy = indexingPolicy,
VectorEmbeddingPolicy = new(
[
new Microsoft.Azure.Cosmos.Embedding
{
DataType = VectorDataType.Float32,
Dimensions = 1536,
DistanceFunction = DistanceFunction.Cosine,
Path = "/embedding"
},
]),
});
this.container = containerResponse.Container;
if (containerResponse.StatusCode != System.Net.HttpStatusCode.OK)
{
this.LogHeaders(containerResponse.Headers);
}
}