Skip to content

Latest commit

History

History
31 lines (23 loc) 路 902 Bytes

count.md

File metadata and controls

31 lines (23 loc) 路 902 Bytes

Count

A count request executes a query and returns a count of the number of matching documents for that query. It can be executed across one or more indices. The query can be omitted for a total count across the indexes.

To count all documents in an index regardless of type, we can do this.

client.execute {
  count("places")
}

We can do multiple indexes at once.

client.execute {
  count(Seq("places", "movies"))
}

We can include a query to narrow down the results.

client.execute {
  count("places").query(termQuery("borough", "westminster"))
}

There are multiple options on count, such as expand wilcards, ignore throttled, and so on. See the official docs for a full list.