Skip to contents

A convenience wrapper that infers a schema from data, creates an index, adds every row and commits. Text columns are made searchable; filter columns are indexed for filtering and ordering; all other columns are stored so they are returned by tnt_search().

Usage

tnt_index_df(
  data,
  text,
  filters = NULL,
  stemmer = "none",
  stopwords = FALSE,
  stored = TRUE,
  path = NULL,
  overwrite = FALSE,
  heap_mb = 128
)

Arguments

data

A data frame.

text

<tidy-select> Columns to index as full-text fields.

filters

<tidy-select> Columns to index for filtering/ordering (their type is inferred). Optional.

stemmer, stopwords

Stemming and stop-word options applied to all text columns. See tnt_text().

stored

Logical. Store text columns so they are returned by searches.

path, overwrite, heap_mb

Passed to tnt_index().

Value

A committed tnt_index object.

Examples

df <- data.frame(
  id = 1:2,
  title = c("Orçamento público aprovado", "Reforma tributária avança"),
  year = c(2023L, 2024L)
)
idx <- tnt_index_df(df, text = title, filters = year, stemmer = "portuguese")
tnt_search(idx, "orcamento")
#> # A tibble: 0 × 4
#> # ℹ 4 variables: score <dbl>, id <dbl>, title <chr>, year <dbl>