# Querying Your Pinecone Index with Metadata Filters to Retrieve Vectors that Belong to Specific Clusters After you have assigned cluster labels to your vectors and stored them in Pinecone with metadata (including these cluster labels), you can perform targeted queries to find vectors within a particular cluster. Here's how you can query an index with metadata filters, according to the documents: 1. **Prepare Your Query**: Decide on the vector you want to query against and the metadata filter conditions. For instance, if you want to find vectors that belong to a specific cluster, you'll use the cluster label as your filter criterion. 2. **Use Metadata Filters in Your Query**: When you send a query to Pinecone, include a filter condition that specifies the cluster label. Pinecone's querying mechanism allows you to use various filter conditions based on the metadata you’ve stored. Here's an example of querying by vector and filtering by cluster label: ```python from pinecone import Pinecone # Initialize and select your index pc = Pinecone(api_key="YOUR_API_KEY") index = pc.Index("pinecone-index") # Example query vector (replace with your actual query vector) query_vector = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] # Querying the index with a metadata filter for the cluster label index.query( vector=query_vector, filter={"cluster_label": {"$eq": "specific_cluster_label"}}, top_k=5, include_metadata=True ) ``` 3. **Execute the Query**: When executing the query, Pinecone retrieves vectors that are both similar to your query vector and match the filter conditions based on the metadata. This allows you to effectively retrieve vectors from a specific cluster. 4. **Review Query Results**: The query result will include the vectors that met both the similarity and metadata filter criteria. By using the `include_metadata=True` flag, you can also see the metadata (including cluster labels) of the retrieved vectors, helping you verify that they belong to the desired cluster. This approach leverages Pinecone's capability to filter queries based on metadata, enabling you to perform efficient and targeted searches within your vector space according to the cluster assignments you've made previously.