Queries can be 'instructed' to wait for non-stale results for a specified amount of time using the
WaitForNonStaleResults method. If the query won't be able to return
non-stale results within the specified (or default) timeout, then a
TimeoutException is thrown.
If a query sent to the server specifies that it needs to wait for non-stale results, then RavenDB sets the cutoff Etag for the staleness check.
It is the Etag of the last document (or document tombstone), from the collection(s) processed by the index, as of the query arrived to the server.
This way the server won't be waiting forever for the non-stale results even though documents are constantly updated meanwhile.
If the last Etag processed by the index is greater than the cutoff then the results are considered as non-stale.
IDocumentQueryCustomization WaitForNonStaleResults(TimeSpan? waitTimeout);
||Time to wait for an index to return non-stale results. The default is 15 seconds.
||Returns self for easier method chaining.
List<Employee> results = session.Query<Employee>()
.Customize(x => x.WaitForNonStaleResults())
.Where(x => x.FirstName == "Robert")