開始使用免費開始

多重中繼資料篩選

除了等於運算之外,Pinecone 也提供其他核心比較運算子,並允許在單一查詢中使用多個篩選條件。這個練習中,你將使用 Pinecone 的其他比較運算子建立多個篩選條件,並用它們重新查詢你的索引。

本練習屬於課程

使用 Pinecone 構建 AI 應用

檢視課程

練習說明

  • 使用你的 API 金鑰初始化 Pinecone 連線。
  • 只在中繼資料 "genre""thriller""year" 小於 2018 的向量中,找出與提供的 vector 最相似(MOST)的向量。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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)
編輯並執行程式碼