stats
The stats:​*
category groups stages returning statistics about a specific analysis result, such as a
document list.
You can use the following statistics stages in your analysis requests:
-
stats:​documents
-
Returns statistics related to the list of documents you provide.
The structure of the JSON output is specific to each statistics stage.
stats:​documents
Returns statistics related to the list of documents you provide. Typically, the count of documents in the
referenced stage. An optional matches
element may contain the total hit count and information whether
the total is approximate or exact.
{
"type": "stats:documents",
"documents": {
"type": "documents:reference",
"auto": true
}
}
For example, this request asks for an exact count of documents matching the query photon:
The response for the above request contains the number of documents contained by the nested
documents:​by​Query
stage (10, as per
the requested limit
) and the total number of matches in the index:
The document count returned by the stats:​documents
stage is particularly useful when the number of
documents cannot be determined in advance. For example, consider this request, which displays statistics for the
documents:​sample
stage:
In this case, both the number of matching documents, and the number of documents returned within the sample, are hard to predict. The output for this request reveals both:
documents
A reference to one of the documents:​*
stages for which
the statistics should be returned.