Check if document exists based on index

Im trying to know weather or not i need to create a new document for a unknown UUID or update an existing one, i have some code working with exists and an index, but it causes an error if it wasnt found by the index, am i doing something wrong?

Probably a silly question but i cant seem to work it out

Typically, if there’s an index entry, the document that the index entry was created for does exist. That guarantee lasts for the duration of the current transaction.

Can you show us the index definition, and the query that you are trying to use?

i actually already found it, sorry