Count documents in aliases
Counts documents across one or more aliases (and, if needed, a mix of indexes and aliases) using the Elasticsearch query DSL. Use the Index parameter to list the aliases and indexes to include, and optionally pass a query expression to count only matching documents; see the Elasticsearch query DSL documentation for details.
SELECT * FROM count WITH(Index='MyIndexOrAliasName') -- get count of documents in index / alias named MyIndexOrAliasName
SELECT * FROM count WITH(Index='*') -- get count of documents in all indices (total distinct _id found across all indices + alias)
SELECT * FROM count WITH(Index='MyIndexOrAlias1,MyIndexOrAlias2') -- get count of documents in MyIndex1 and MyIndex2
SELECT * FROM count WITH(Index='MyIndex', Query='{"match": { "comment" : "TV" } }') -- get count of documents in index named MyIndex where comment field contains word "TV"
SELECT * FROM count WITH(Index='MyAlias', Query='{"match": { "comment" : "TV" } }') -- get count of documents in alias named MyAlias where comment field contains word "TV"