Get Query Statistics

Query statistics can provide important information about a query like duration, total number of results, staleness information, etc. To access statistics use the statistics method.


Reference<QueryStatistics> stats = new Reference<>();

List<Employee> employees = session.query(Employee.class)
    .whereEquals("FirstName", "Robert")

int totalResults = stats.value.getTotalResults();
long durationInMs = stats.value.getDurationInMs();


IDocumentQuery<T> statistics(Reference<QueryStatistics> stats);
stats QueryStatistics Statistics for query.

public class QueryStatistics {

    private boolean isStale;
    private long durationInMs;
    private int totalResults;
    private long longTotalResults;
    private int skippedResults;
    private Date timestamp;
    private String indexName;
    private Date indexTimestamp;
    private Date lastQueryTime;
    private Long resultEtag;
    private String nodeTag;
Property Type Description
IsStale boolean Are the results returned by the query potentially stale
DurationInMs long Query duration on the server side in Milliseconds
TotalResults int The total count of results that matched the query as int
LongTotalResults long The total count of the results that matched the query as long
SkippedResults int The number of results skipped by the server.
Learn more in paging through tampered results.
Timestamp Date The time when the query results were unstale
IndexName string The name of the queried index
indexTimestamp Date The timestamp of the queried index
LastQueryTime Date The timestamp of the last time the index was queried
ResultEtag Long Results Etag
NodeTag String Tag of the cluster node that responded to the query