Find answers from the community

Updated 2 months ago

Using integer ids for documents in db

hey anyone know how if we can use integer ids for Documents? Trying to set them up that way to reference other documents i have in my db
W
a
L
6 comments
Its of type str but you can add your DB ids. Also if you want to compare then just need to change the type from str to int.

doc = Document(doc_id='1', text="This is a text")
i want to use integer ids for upserts into my db because I want each of my embedding rows to reference the original document id from another table which is an int. If i just provide the str representation of the id, it will use that consistently so I will not be able to do my referencing.
I can maybe look into casting on upserts but it seems so weird that the default id on docs only accepts str
Not that weird 🤷 the vector store class can handle it however you want, but people often set ids to filenames, etc

Some vector dbs even enforce formats, like qdrant only works with uuid
@Logan M I'm assuming you're the same person that kindly responded to the issue opened on this so let's continue discussion there to avoid duplication : https://github.com/run-llama/llama_index/issues/16579. Just sending this here for anyone else who wants to follow
Yea that was me (I'm the core maintainer at the moment)
Add a reply
Sign up and join the conversation on Discord