Q. What role does a pod play in a vector database index?
A. It represents pre-configured hardware for efficient data retrieval
pinecone.create_collection(name = "my-collection", source = "test")
pinecone.list_collections() # list all collections in database
res = pinecone.describe_collection("my-collection")
res.name # 결과는 'my-collection'
res.size / 10**6 # MB단위, 결과는 3.112836
pinecone.delete_collection("my-collection")
""
)'''
upsert할 때 namespace를 지정하는 예시
'''
idx = pinecone.Index("my-collection-index") # connect to index
### 기타 코드 생략 ###
idx.upsert(vectors_subj, namespace='subject')
'''
query할 때 namespace를 사용하는 예시
'''
### 기타 코드 생략 ###
idx.query(vector = list(np.random.rand(3)),
top_k=3,
namespace='',
include_values=True)
여기서 {"topic": ~~~~, "year": ~~~~}
부분이 metadata.
idx.upsert([
("1", [0.1, 0.1, 0.1 ], {"topic": "subject", "year": 2023}),
("2", [0.2, 0.2, 0.2], {"topic": "other", "year": 2024}),
("3", [0.3, 0.3, 0.3], {"topic": "body", "year": 2023}),
("4", [0.4, 0.4, 0.4], {"topic": "body"}),
("5", [0.5, 0.5, 0.5], {"topic": "subject"})
])
idx.query(vector =[0,0,0],
top_k=2,
include_metadata=True,
include_values=True,
filter={
"topic" : {"$eq": "subject"},
"year" : 2023
})