You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code configures either a `DiskANN` or `quantizedFlat` vector algorithm from environment variables, connects to Azure OpenAI and Cosmos DB using passwordless authentication, loads pre-vectorized hotel data from a JSON file, inserts it into the appropriate container, then generates an embedding for a natural-language query (`quintessential lodging near running trails, eateries, retail`) and executes a VectorDistance SQL query to retrieve the top 5 most semantically similar hotels ranked by similarity score.
206
+
This code configures either a `DiskANN` or `quantizedFlat` vector algorithm from environment variables, connects to Azure OpenAI and Azure Cosmos DB using passwordless authentication, loads pre-vectorized hotel data from a JSON file, inserts it into the appropriate container, then generates an embedding for a natural-language query (`quintessential lodging near running trails, eateries, retail`) and executes a VectorDistance SQL query to retrieve the top 5 most semantically similar hotels ranked by similarity score.
This OpenAI API call for [client.embeddings.create](https://platform.openai.com/docs/guides/embeddings#how-to-get-embeddings) converts text like "quintessential lodging near running trails" into a 1536-dimension vector that captures its semantic meaning. For more details on generating embeddings, see [Azure OpenAI embeddings documentation](/azure/ai-foundry/openai/how-to/embeddings).
222
222
223
-
## Understand the code: Store vectors in Cosmos DB
223
+
## Understand the code: Store vectors in Azure Cosmos DB
224
224
225
225
All documents with vector arrays are inserted at scale using the [`executeBulkOperations`](/javascript/api/%40azure/cosmos/items#@azure-cosmos-items-executebulkoperations) function:
226
226
@@ -267,7 +267,7 @@ Paste the following code into `utils.ts`:
267
267
This utility module provides these **key** functions:
268
268
269
269
- `getClientsPasswordless`: Creates and returns clients for Azure OpenAI and Azure Cosmos DB using passwordless authentication. Enable RBAC on both resources and sign in to Azure CLI
270
-
- `insertData`: Inserts data in batches into a Cosmos DB container and creates standard indexes on specified fields
270
+
- `insertData`: Inserts data in batches into an Azure Cosmos DB container and creates standard indexes on specified fields
271
271
- `printSearchResults`: Prints the results of a vector search, including the score and hotel name
272
272
- `validateFieldName`: Validates that a field name exists in the data
273
273
- `getBulkOperationRUs`: Estimates the Request Units (RUs) for bulk operations based on the number of documents and vector dimensions
@@ -321,7 +321,7 @@ The app logging and output show:
321
321
322
322
## Distance metrics
323
323
324
-
Azure Cosmos DB for NoSQL supports three distance functions for vector similarity:
324
+
Azure Cosmos DB supports three distance functions for vector similarity:
325
325
326
326
| Distance Function | Score Range | Interpretation | Best For |
0 commit comments