|
10 | 10 | import test_config |
11 | 11 | from azure.cosmos import CosmosClient, PartitionKey |
12 | 12 |
|
| 13 | +VectorPolicyTestData = { |
| 14 | + "valid_vector_indexing_policy" : { |
| 15 | + "indexing_policy": { |
| 16 | + "vectorIndexes": [ |
| 17 | + {"path": "/vector1", "type": "flat"}, |
| 18 | + {"path": "/vector2", "type": "quantizedFlat", "quantizerType": "product", "quantizationByteSize": 8}, |
| 19 | + {"path": "/vector3", "type": "diskANN", "quantizerType": "product", "quantizationByteSize": 8, |
| 20 | + "vectorIndexShardKey": ["/city"], "indexingSearchListSize": 50}, |
| 21 | + {"path": "/vector4", "type": "diskANN", "quantizerType": "spherical", "indexingSearchListSize": 50}, |
| 22 | + ] |
| 23 | + }, |
| 24 | + "vector_embedding_policy": { |
| 25 | + "vectorEmbeddings": [ |
| 26 | + { |
| 27 | + "path": "/vector1", |
| 28 | + "dataType": "float32", |
| 29 | + "dimensions": 256, |
| 30 | + "distanceFunction": "euclidean" |
| 31 | + }, |
| 32 | + { |
| 33 | + "path": "/vector2", |
| 34 | + "dataType": "int8", |
| 35 | + "dimensions": 200, |
| 36 | + "distanceFunction": "dotproduct" |
| 37 | + }, |
| 38 | + { |
| 39 | + "path": "/vector3", |
| 40 | + "dataType": "uint8", |
| 41 | + "dimensions": 400, |
| 42 | + "distanceFunction": "cosine" |
| 43 | + }, |
| 44 | + { |
| 45 | + "path": "/vector4", |
| 46 | + "dataType": "uint8", |
| 47 | + "dimensions": 400, |
| 48 | + "distanceFunction": "euclidean" |
| 49 | + }, |
| 50 | + ] |
| 51 | + } |
| 52 | + } |
| 53 | +} |
13 | 54 |
|
14 | 55 | @pytest.mark.cosmosSearchQuery |
15 | 56 | class TestVectorPolicy(unittest.TestCase): |
@@ -55,6 +96,21 @@ def test_create_valid_vector_embedding_policy(self): |
55 | 96 | assert properties["vectorEmbeddingPolicy"]["vectorEmbeddings"][0]["dataType"] == data_type |
56 | 97 | self.test_db.delete_container('vector_container_' + data_type) |
57 | 98 |
|
| 99 | + @unittest.skip |
| 100 | + def test_create_valid_vector_indexing_policy(self): |
| 101 | + test_data = VectorPolicyTestData["valid_vector_indexing_policy"] |
| 102 | + indexing_policy = test_data["indexing_policy"] |
| 103 | + vector_embedding_policy = test_data["vector_embedding_policy"] |
| 104 | + |
| 105 | + created_container = self.test_db.create_container( |
| 106 | + id="container_" + str(uuid.uuid4()), |
| 107 | + partition_key=PartitionKey(path="/id"), |
| 108 | + vector_embedding_policy=vector_embedding_policy, |
| 109 | + indexing_policy=indexing_policy) |
| 110 | + properties = created_container.read() |
| 111 | + assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] |
| 112 | + self.test_db.delete_container(created_container.id) |
| 113 | + |
58 | 114 | def test_create_vector_embedding_container(self): |
59 | 115 | indexing_policy = { |
60 | 116 | "vectorIndexes": [ |
|
0 commit comments