I tried to retrieve documents with similar content to later modify them, but when it came to updating, I realized I couldn't get the ID to update these documents.
Here’s the function I was using to retrieve documents:
def retrieve(text):
"""Retrieve information related to a query."""
retrieved_docs = db.similarity_search(text, k=3)
return retrieved_docs
This is how the document structure looks when printed
Document(metadata={'projectName': ''}, page_content="")
And in Weaviate:
{
"uuid": "",
"metadata": {
"creationTime": ""
},
"properties": {
"projectName": "",
"text": ""
},
"vectors": {
"default": []}}
And here’s the db configuration, don't know, maybe it helps:
db = WeaviateVectorStore(
client=client,
index_name="Cases",
embedding=embedding_model,
text_key="text"
)
I haven't found any information about a similar case, everywhere people are interacting with existing uuid. How to get uuid? Or maybe there’s another way to achieve this? For example, saving information as new each time, but will this compromise accuracy over time?
I’d appreciate your response!
Duda Nogueira from Weaviate here!
Can you confirm you are using Langchain and not Llamaindex?
For Langchain, you need to explicitly request this with;
docs = db.similarity_search("traditional food", return_uuids=True)
print(docs[0].metadata.get("uuid"))
I just noticed this is an undocumented feature! I have added it here in our langchain recipes to make it visible:
https://github.com/weaviate/recipes/tree/main/integrations/llm-frameworks/langchain/loading-data
Let me know if this helps!
Thanks!