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
When using the `pymongo` client, the creation of a database is automatic when referenced. No specific api calls to create a database are required, if a database already exists, a reference to the database is returned.
56
56
57
-
>**Note:**: That the creation of databases and containers are lazy, meaning they will not be created until a document is inserted into a collection.
57
+
>**Note:**: That the creation of databases and containers are lazy, meaning they will not be created until a document is inserted into a container.
58
58
59
59
```python
60
60
db = client.cosmic_works
61
61
```
62
62
63
-
### Creating a collection
63
+
### Creating a container
64
64
65
-
Similar behavior to the creation of a database is experienced when creating a collection. If the collection does not exist, it will be created once a document is inserted into the collection.
65
+
Similar behavior to the creation of a database is experienced when creating a container. If the container does not exist, it will be created once a document is inserted into the container.
66
66
67
67
```python
68
68
collection = db.products
69
69
```
70
70
71
71
### Creating a document
72
72
73
-
The `insert_one` method is used to insert a document into a collection. The document is a dictionary object.
73
+
The `insert_one` method is used to insert a document into a container. The document is a dictionary object.
74
74
75
75
```python
76
76
# Insert the JSON into the database, and retrieve the inserted/generated ID
Copy file name to clipboardExpand all lines: 08_Load_Data/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Load data into Azure Cosmos DB API for NoSQL
2
2
3
-
The previous lab demonstrated how to add data to a collection individually. This lab will demonstrate how to load data using bulk operations into multiple collections. This data will be used in subsequent labs to explain further the capabilities of Azure Cosmos DB API about AI.
3
+
The previous lab demonstrated how to add data to a container individually. This lab will demonstrate how to load data using bulk operations into multiple containers. This data will be used in subsequent labs to explain further the capabilities of Azure Cosmos DB API about AI.
4
4
5
5
When loading data, bulk operations are preferred over adding each document individually. Bulk operations involve performing multiple database operations as a batch rather than executing them simultaneously. This approach is more efficient and provides several benefits:
Copy file name to clipboardExpand all lines: 09_Vector_Search_Cosmos_DB/README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
Embedding is a way of serializing the semantic meaning of data into a vector representation. Because the generated vector embedding represents the semantic meaning, it means that when it is searched, it can find similar data based on the semantic meaning of the data rather than exact text. Data can come from many sources, including text, images, audio, and video. Because the data is represented as a vector, vector search can, therefore, find similar data across all different types of data.
8
8
9
-
Embeddings are created by sending data to an embedding model, where it is transformed into a vector, which then can be stored as a vector field within its source document in Azure Cosmos DB for NoSQL. Azure Cosmos DB for NoSQL supports the creation of vector search indexes on top of these vector fields. A vector search index is a collection of vectors in [latent space](https://idl.cs.washington.edu/papers/latent-space-cartography/) that enables a semantic similarity search across all data (vectors) contained within.
9
+
Embeddings are created by sending data to an embedding model, where it is transformed into a vector, which then can be stored as a vector field within its source document in Azure Cosmos DB for NoSQL. Azure Cosmos DB for NoSQL supports the creation of vector search indexes on top of these vector fields. A vector search index is a container of vectors in [latent space](https://idl.cs.washington.edu/papers/latent-space-cartography/) that enables a semantic similarity search across all data (vectors) contained within.
10
10
11
11

The lab creates an embedding field named `contentVector` in each collection and populates the value with the vectorized text of the JSON representation of the document.
77
+
The lab creates an embedding field named `contentVector` in each container and populates the value with the vectorized text of the JSON representation of the document.
Copy file name to clipboardExpand all lines: 10_LangChain/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,7 @@ rag_chain = (
67
67
68
68
### Creating tools for LangChain agents to use
69
69
70
-
Tools are selected by the Large Language model at runtime. In this case, depending on the incoming user request the LLM will decide which collection in the database to query. The following code shows how to create a tool for the LLM to use to query the products collection in the database.
70
+
Tools are selected by the Large Language model at runtime. In this case, depending on the incoming user request the LLM will decide which container in the database to query. The following code shows how to create a tool for the LLM to use to query the products collection in the database.
71
71
72
72
```python
73
73
# create a chain on the retriever to format the documents as JSON
Copy file name to clipboardExpand all lines: Labs/lab_1_first_application.ipynb
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@
53
53
"source": [
54
54
"## Create a container\n",
55
55
"\n",
56
-
"Creating containers behaves similarly to the database creation. If the collection does not exist, it will be created. It's important to note that databases and containers are lazily created. This means that the database and collection will not be created until the first document is inserted."
56
+
"Creating containers behaves similarly to the database creation. If the container does not exist, it will be created. It's important to note that databases and containers are lazily created. This means that the database and container will not be created until the first document is inserted."
57
57
]
58
58
},
59
59
{
@@ -107,7 +107,7 @@
107
107
"source": [
108
108
"## Read a document\n",
109
109
"\n",
110
-
"The insertion of the Product in the previous cell automatically created the database and collection. The `find_one` method is used to retrieve a single document from the database. The `find_one` method takes a filter as an argument. This filter is used to find the document in the database. In this case, the filter is the unique identifier or `_id` of the document that was just inserted."
110
+
"The insertion of the Product in the previous cell automatically created the database and container. The `find_one` method is used to retrieve a single document from the database. The `find_one` method takes a filter as an argument. This filter is used to find the document in the database. In this case, the filter is the unique identifier or `_id` of the document that was just inserted."
111
111
]
112
112
},
113
113
{
@@ -185,7 +185,7 @@
185
185
"source": [
186
186
"## Query for multiple documents\n",
187
187
"\n",
188
-
"The `find` method is used to query for multiple documents in the database. This method takes a filter as an argument. This filter is used to find the documents to return. In this case, the filter is an empty dictionary. This will return all documents in the collection."
188
+
"The `find` method is used to query for multiple documents in the database. This method takes a filter as an argument. This filter is used to find the documents to return. In this case, the filter is an empty dictionary. This will return all documents in the container."
189
189
]
190
190
},
191
191
{
@@ -277,7 +277,7 @@
277
277
"source": [
278
278
"## Clean up resources\n",
279
279
"\n",
280
-
"The following cell will delete the database and collection created in this lab. This is done by using the `drop_database` method on the database object. This method takes the name of the database to delete as an argument. If it is desired to simply delete the collection, the `drop_collection` method can be used on the database object. This method takes the name of the collection to delete as an argument."
280
+
"The following cell will delete the database and container created in this lab. This is done by using the `drop_database` method on the database object. This method takes the name of the database to delete as an argument. If it is desired to simply delete the container, the `drop_collection` method can be used on the database object. This method takes the name of the container to delete as an argument."
Copy file name to clipboardExpand all lines: Labs/lab_3_mongodb_vector_search.ipynb
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -272,7 +272,7 @@
272
272
"source": [
273
273
"## Use vector search in Azure Cosmos DB for NoSQL\n",
274
274
"\n",
275
-
"Now that each document has its associated vector embedding and the vector indexes have been created on each collection, we can now use the vector search capabilities of Azure Cosmos DB for NoSQL."
275
+
"Now that each document has its associated vector embedding and the vector indexes have been created on each container, we can now use the vector search capabilities of Azure Cosmos DB for NoSQL."
Copy file name to clipboardExpand all lines: Labs/lab_4_langchain.ipynb
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@
78
78
"\n",
79
79
"In the previous lab, the `pymongo` library was used to perform a vector search through a db command to find product documents that were most similar to the user's input. In this lab, you will use the `langchain` library to perform the same search. LangChain has a vector store class named **AzureCosmosDBVectorSearch**, a community contribution, that supports vector search in Azure Cosmos DB for NoSQL.\n",
80
80
"\n",
81
-
"When establishing the connection to the vector store (Azure Cosmos DB for NoSQL), recall that in previous labs the products collection was populated and a contentVector field added that contains the vectorized embeddings of the document itself. Finally, a vector index was also created on the contentVector field to enable vector search. The vector index in each collection is named `VectorSearchIndex`.\n",
81
+
"When establishing the connection to the vector store (Azure Cosmos DB for NoSQL), recall that in previous labs the products container was populated and a contentVector field added that contains the vectorized embeddings of the document itself. Finally, a vector index was also created on the contentVector field to enable vector search. The vector index in each container is named `VectorSearchIndex`.\n",
82
82
"\n",
83
83
"The return value of a vector search in LangChain is a list of `Document` objects. The LangChain `Document` class contains two properties: `page_content`, that represents the textual content that is typically used to augment the prompt, and `metadata` that contains all other attributes of the document. In the cell below, we'll use the `_id` field as the page_content, and the rest of the fields are returned as metadata.\n",
0 commit comments