篩選查詢
在這個練習中,你將實作查詢 'datacamp-index' 這個 Pinecone 索引。你會連線到該索引,並使用提供的 vector 來查找相似的向量。同時,你也會使用中繼資料篩選來最佳化查詢,返回最相關的搜尋結果。
本練習屬於課程
使用 Pinecone 構建 AI 應用
練習說明
- 使用你的 API 金鑰初始化 Pinecone 連線。
- 只在中繼資料中
'year'等於2024的向量裡搜尋,取回與提供的vector最相似的向量(也就是 MOST 相似)。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")
index = pc.Index('datacamp-index')
# Retrieve the MOST similar vector with the year 2024
query_result = ____
print(query_result)