Strange results with documentDb

I have two queries that I executed in a documentDb database.

The second query is more restrictive than the first, but I get a register that I don´t get in the first query.

The second query return the '9ad1b2c0-3084-4903-b9a2-f8fa8e30d3a4' id that I am waiting in the first query...

I tried these queries in the Query browser at Azure Portal with my Document db database with the same results.

Query:

1)

    SELECT c.id FROM c where c.BatchInfo.Id='1b47970d-df41-41f6-8666-16017f50db55'

Result:

    [
        {id : efc31b18-15b0-477c-9cbd-ee74b489b6e2 }, 
        {id : c43a654a-5a1a-47a4-b3ce-28629db16c38 }, 
        {id : aef97bcc-ea26-4c3e-9591-ff68ea1d4293 } 
    ]

2)

    SELECT c.id FROM c where c.id= '9ad1b2c0-3084-4903-b9a2-f8fa8e30d3a4' and c.BatchInfo.Id='1b47970d-df41-41f6-8666-16017f50db55'

Result:

    [{id : 9ad1b2c0-3084-4903-b9a2-f8fa8e30d3a4 } ]

Upvotes: 2

Views: 71

Answers (1)

This is happening for use lazy indexing mode.

Lazy indexing as the name suggests is performed as a low priority process relative to writes and serves "eventually consistent results" to queries.

To avoid this problem, you should change your indexing mode to "Consistent" in the documentCollection.

Upvotes: 4

Related Questions