Sorting Discrepancies


We are querying CB using the Java SDK and the view being queried is to be sorted by a specific attribute of the documents. For instance, each document has a field which represents the state, this state is a string.

When querying this view we experience the following problem:

We have three documents with states B,C and D. When we query, we get them in alphabetic order (B,C and D). Let’s say that document with state D changes to state A. We expect now to receive the documents in the new order (A,B and C) but we actually get B,C and A. The behavior is as if the sorting was done prior to the document changing state. If we query again, the list will come sorted correctly.

The aforementioned behavior is being experienced even if we query using the Stale property to false.

We believe that the view is sorting before actually fetching the documents and when the documents are fetch they could have changed attributes.

Is there a way to cope with this situation?