You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
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.


public CloseableIterator<RavenJObject> streamQuery(String index, IndexQuery query, Reference<QueryHeaderInformation> queryHeaderInfo);
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


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 =;