@@ -100,16 +100,32 @@ def _create_container(self) -> None:
100100 "automatic" : True ,
101101 "includedPaths" : [{"path" : "/*" }],
102102 "excludedPaths" : [{"path" : "/_etag/?" }, {"path" : "/vector/*" }],
103- "vectorIndexes" : [{"path" : "/vector" , "type" : "diskANN" }],
104103 }
105104
106- # Create the container and container client
107- self ._database_client .create_container_if_not_exists (
108- id = self ._container_name ,
109- partition_key = partition_key ,
110- indexing_policy = indexing_policy ,
111- vector_embedding_policy = vector_embedding_policy ,
112- )
105+ # Currently, the CosmosDB emulator does not support the diskANN policy.
106+ try :
107+ # First try with the standard diskANN policy
108+ indexing_policy ["vectorIndexes" ] = [{"path" : "/vector" , "type" : "diskANN" }]
109+
110+ # Create the container and container client
111+ self ._database_client .create_container_if_not_exists (
112+ id = self ._container_name ,
113+ partition_key = partition_key ,
114+ indexing_policy = indexing_policy ,
115+ vector_embedding_policy = vector_embedding_policy ,
116+ )
117+ except CosmosHttpResponseError :
118+ # If diskANN fails (likely in emulator), retry without vector indexes
119+ indexing_policy .pop ("vectorIndexes" , None )
120+
121+ # Create the container with compatible indexing policy
122+ self ._database_client .create_container_if_not_exists (
123+ id = self ._container_name ,
124+ partition_key = partition_key ,
125+ indexing_policy = indexing_policy ,
126+ vector_embedding_policy = vector_embedding_policy ,
127+ )
128+
113129 self ._container_client = self ._database_client .get_container_client (
114130 self ._container_name
115131 )
0 commit comments