Querying: Query vs DocumentQuery

Unlike .NET client, Java client offers single API for querying documents.

Below you can find examples of equivalent calls.

query method in DocumentSession is shorthand for calling session.advanced().documentQuery.

session.query(Order.class)

is equivalent to:

session.advanced().documentQuery(Order.class)

session.query(Order.class, Orders_ByShipToAndLines.class)

is equivalent to:

session.advanced().documentQuery(Order.class, Orders_ByShipToAndLines.class)

session.query(Order.class, Query.index("Orders/ByShipToAndLines"))

is equivalent to:

session.advanced().documentQuery(Order.class, "Orders/ByShipToAndLines", null, false);

session.query(Order.class, Query.collection("orders"))

is equivalent to:

session.advanced().documentQuery(Order.class, null, "orders", false);