LoslegenKostenlos loslegen

Multiple metadata filters

As well as equality operations, Pinecone provides operators for other core comparison operations, as well as enabling multiple filters in a single query. In this exercise, you'll create multiple filters using Pinecone's other comparison operators and use them to re-query your index.

Diese Übung ist Teil des Kurses

Vector Databases for Embeddings with Pinecone

Kurs anzeigen

Anleitung zur Übung

  • Initialize the Pinecone connection using your API key.
  • Retrieve the MOST similar vector to the vector provided, only searching through vectors where the the "genre" metadata is "thriller" and "year" is less than 2018.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Initialize the Pinecone client using your API key
pc = Pinecone(api_key="____")

index = pc.Index('datacamp-index')

# Retrieve the MOST similar vector with genre and year filters
query_result = index.query(
    vector=vector,
    top_k=1,
    filter=____
)
print(query_result)
Code bearbeiten und ausführen