Get startedGet started for free

Retrieving vectors

1. Retrieving vectors

Welcome back!

2. Recap...

Now that we've created a serverless index with an appropriate dimensionality,

3. Recap...

and added our records, including metadata, it's time to talk about fetching and querying the vectors.

4. Accessing vectors

There are two main methods for accessing vectors from a Pinecone vector database: fetching and querying. Fetching involves finding and returning a record using its ID. This is normally done to explore and verify particular records from the index. Querying involves sending a vector to the index, and returning the vector or vectors that are most similar to it. If vectors were books, fetching would be like using the ISBN, or International Standard Book Number, to find a book. Querying is like searching for books that are similar to one we already own. We'll focus on fetching vectors in this video and querying vectors in the next video.

5. Fetching vectors

To fetch records based on their IDs, we can call the .fetch() method, passing it a list of record IDs to return. We can see the result contains a dictionary under the 'vectors' key that contains one entry for each record returned. From these entries, we can access the vector values and associated metadata. There's also a 'usage' key, which shows we've used one read unit when fetching our vectors. Let's talk about read units.

6. Read units

Read units, or RUs, are a Pinecone-specific measure of the resources consumed during reading operations. Fetching, querying, and listing vectors all consume read units. For fetching, 1RU is consumed for every batch of 10 records retrieved. Fortunately, Pinecone's starter account provides a generous monthly quota of read units for developing and testing solutions before scaling.

7. Fetching vectors from namespaces

Finally, we can also fetch vectors from specific namespaces by specifying the namespace argument. We can see that the previously blank namespace output has now been populated. Later in the course, when we come to storing and querying vectors across multiple namespaces, this functionality will become invaluable.

8. Let's practice!

Time to practice!