migrating-ravens / RavenMigrations

A small migrations framework to help you manage your RavenDB Instance.
MIT License
53 stars 24 forks source link

Ordering of documents in Alter.Collection #10

Closed gareththackeray closed 9 years ago

gareththackeray commented 10 years ago

Alter.Collection does not specify an ordering for the documents. According to this https://groups.google.com/forum/#!topic/ravendb/OgOb8eV3k5Q there is no default ordering so the documents can come out in arbitrary order.

We are running migrations where Alter.Collection misses some documents on its first pass and has to be re-run in order to modify every document. We haven't done detailed analysis on this but looking at the Alter.Collection code there doesn't seem to be anything that could be causing this other than the updates themselves changing the order that items are coming out of the Lucene query.

One option would be to have the query in Alter.Collection order the results by the Last-Modified metadata property in descending order. A better option might be to use the streaming API - is there a reason why you didn't use this in the first place?

Do you have any thoughts?

dportzline83 commented 9 years ago

I believe this issue should be solved by 49447d860d8923940f562e848dcc1def4f068736. Using the streaming api should get all of the documents at the time the stream is started. So, even though the documents will be streamed in an arbitrary order, it shouldn't matter.