Files
fastembed/usage.py
NirantK 81dcb3ae05 * chore(usage.py): update comment to clarify the behavior of the ids list
* fix(usage.py): change comment to reflect that random IDs can lead to duplicates
2023-07-12 16:49:38 +05:30

41 lines
1002 B
Python

from qdrant_client import QdrantClient
# Initialize the client
client = QdrantClient(":memory:") # or QdrantClient(path="path/to/db")
# Prepare your documents, metadata, and IDs
docs = [
"Qdrant has Langchain integrations",
"Qdrant also has Llama Index integrations",
# ...more documents...
]
metadatas = [
{"source": "notion"},
{"source": "google-docs"},
# ...more metadata...
]
ids = [
1,
2,
3,
50,
63,
] # unique for each doc, if not mentioned, we'll generate random IDs, can lead to duplicates
# Use the new upsert_docs method
client.upsert_docs(
collection_name="demo_collection",
docs={"documents": docs, "metadatas": metadatas, "ids": ids},
batch_size=512, # Adjust as needed
wait=True, # Wait for the operation to complete
)
search_result = client.query(
collection_name="demo_collection",
query_texts=["This is a query document"],
n_results=2,
with_vectors=True,
with_payload=True,
)
print(search_result)