see on GitHub

Commands: Querying: How to stream query results?

Use StreamQuery method to stream results of a selected index according to a specified query.

Syntax

public CloseableIterator<RavenJObject> streamQuery(String index, IndexQuery query, Reference<QueryHeaderInformation> queryHeaderInfo);

Parameters
index String A name of an index to query
query IndexQuery A query definition containing all information required to query a specified index.
queryHeaderInfo Reference<QueryHeaderInformation > Information about performed query
Return Value
IEnumerator<RavenJObject> Enumerator with query results
Reference<QueryHeaderInformation > Information about performed query

Example

Reference<QueryHeaderInformation> queryHeaderInfoRef = new Reference<>();
try (CloseableIterator<RavenJObject> iterator = store.getDatabaseCommands().streamQuery("Orders/Totals", new IndexQuery("Company:companies/1"), queryHeaderInfoRef)) {

  while (iterator.hasNext()) {
    RavenJObject order = iterator.next();
  }
}