View Query returns incorrect/multiple results

I’m running a query on a view that returns accurate results about 50% of the time when I add an record and then update the record.

The other half of the time, the query return multiple results…essentially a instance each time the record is updated (i.e. I create a record with name A, change the name to B, and then change the name to C, the query returns 3 records A, B and C). If I delete one record, all three are deleted.

In some instances, if I create record and run the query, it returns 0 records.

Is this an issue of the views not getting re-indexed or is stale ? do I need to refresh the views or run the query different? I currently check if the query is stale, if it is then I run the query again once more…but that doesn’t seem to fix the problem. Do I need to manually delete the index and force the index to re-generate ?

What platform? And can you show some code snippets of how you update the documents?

I was able to track down the issue, there was a code path that was creating a new document every time there was an update. Deletion was deleting all documents because it was keying off of another property that was the same for all documents.