Is there any way to tell RavenDb to use WaitForNonStaleResults mode for all queries of some DocumentStore or DocumentSession?
Asked
Active
Viewed 885 times
1 Answers
9
You can use DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites
at the DocumentStore or Session level.
DocumentStore:
IDocumentStore store = new DocumentStore {
Url = "http://127.0.0.1:8080",
DefaultDatabase = "DBNAME",
Conventions = {
DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites
}
}.Initialize();
Session:
session.Advanced.Conventions.DefaultQueryingConsistency =
ConsistencyOptions.QueryYourWrites;
Bear in mind that this mechanism does not work for Map-Reduce Indexes
You can check Matt's comments on this matter below

Community
- 1
- 1

Carlos Mendes
- 1,900
- 1
- 18
- 33
-
1One thing to note, QueryYourWrites doesn't work with Map/Reduce indexes. For these you have to use WaitForNonStaleResults..() – Matt Warren Dec 19 '11 at 09:54
-
1Matt Warren, what do you mean? I thought all indexes in RavenDb are map-reduce indexes... – SiberianGuy Dec 20 '11 at 05:29
-
@Idsa hopefully I've cleared this up in my answer here http://stackoverflow.com/a/8573878/4500 – Matt Warren Dec 20 '11 at 10:17