Skip to contents

Returns the total number of documents matching a query and optional filter, ignoring any result limit.

Usage

tnt_count(idx, query = "", fields = NULL, filter = NULL)

Arguments

idx

A tnt_index.

query

A query string in tantivy's query syntax. The empty string "" matches all documents (useful with filter).

fields

<tidy-select> Text fields searched for bare (unqualified) query terms. Defaults to all indexed text fields.

filter

Either a tantivy query string, or a comparison expression such as year >= 2020 & source == "globo". Supported operators: ==, %in%, >, >=, <, <=, combined with & and |.

Value

A single numeric count.

See also

Examples

idx <- tnt_index_df(
  data.frame(t = c("apple pie", "apple tart", "banana bread")),
  text = t, stemmer = "english"
)
tnt_count(idx, "apple")
#> [1] 2