Skip to content

Tantivy

Rank documents by BM25 relevance, tokenize text, and stem words with Snowball stemmers for many languages

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/tantivy/index.md to help me query Tantivy with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Rank a small JSON corpus by BM25 relevance to a query, best score first.

Example output · captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT doc_id, score
FROM tantivy.main.bm25_search('["the cat sat","dogs bark","stock crash"]', 'cat')
ORDER BY score DESC, doc_id
Result
doc_id score
0 0.8782

Quick start

Choose where to run Tantivy, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'tantivy' AS tantivy (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-tantivy'
);

3. Run a query

query.sql
SELECT doc_id, score
FROM tantivy.main.bm25_search('["the cat sat","dogs bark","stock crash"]', 'cat')
ORDER BY score DESC, doc_id
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'tantivy' AS tantivy (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Full-text search (BM25 ranking), tokenization, and Snowball stemming, powered by the tantivy search engine.

Catalog

Everything tantivy exposes once attached — read straight from the worker's released build.

tantivy 1 schema
main 1 table · 4 functions

Full-text search, relevance scoring, and text-analysis functions.

Schema examples (9)
Examples (9)

Rank a small JSON corpus by BM25 relevance to a query, best score first.

SELECT doc_id, score
FROM tantivy.main.bm25_search('["the cat sat","dogs bark","stock crash"]', 'cat')
ORDER BY score DESC, doc_id;
Result
doc_id score
0 0.8782

Compute the ad-hoc BM25 score of a single document against a query.

SELECT tantivy.main.bm25_score('the cat sat on the mat', 'cat') AS score;

Tokenize text into lowercased word tokens (no stemming).

SELECT tantivy.main.tokenize('Running quickly, CATS!') AS tokens;

Tokenize and Snowball-stem text for a language.

SELECT tantivy.main.tokenize('Running quickly', 'english') AS tokens;
5 more examples

Snowball-stem a single word to its root for a language.

SELECT tantivy.main.stem('running', 'english') AS root;

List the first few supported Snowball stemmer languages, alphabetically.

SELECT lang FROM tantivy.main.supported_languages ORDER BY lang LIMIT 5;

Rank product titles for 'running OR shoes' with bm25_search, join the hits back to the titles by id, and use tokenize(…, 'english') to list which stemmed query terms each hit contains.

SELECT p.title, round(h.score, 3) AS score,
  list_sort(list_intersect(tantivy.main.tokenize(p.title, 'english'), tantivy.main.tokenize('running shoes', 'english'))) AS matched_terms
FROM tantivy.main.bm25_search('[{"id":1,"text":"Trail running shoes"},{"id":2,"text":"Leather dress shoes"},{"id":3,"text":"Runners guide to the marathon"},{"id":4,"text":"Cast iron skillet"},{"id":5,"text":"Running socks"}]', 'running OR shoes') AS h
JOIN (VALUES (1, 'Trail running shoes'), (2, 'Leather dress shoes'), (3, 'Runners guide to the marathon'), (4, 'Cast iron skillet'), (5, 'Running socks')) AS p(id, title) ON p.id = h.doc_id
ORDER BY h.score DESC, p.title;

Tokenize a sentence (no stemming), then stem each token with stem() to group the word variants under their English Snowball root, most frequent root first.

SELECT tantivy.main.stem(tok, 'english') AS root,
  list(DISTINCT tok ORDER BY tok) AS variants, count(*) AS occurrences
FROM unnest(tantivy.main.tokenize('Runners were running; the runner runs and ran a run.')) AS u(tok)
GROUP BY root
ORDER BY occurrences DESC, root;

Stem the word 'connections' with every supported Snowball stemmer (one row per language from supported_languages) and keep only the languages whose stemmer changes it.

SELECT lang, tantivy.main.stem('connections', lang) AS root
FROM tantivy.main.supported_languages
WHERE tantivy.main.stem('connections', lang) <> 'connections'
ORDER BY lang;
Tables
supported_languages 5 examples1 col

The Snowball stemmer language ids this worker supports (valid lang values for tokenize, stem, and the search analyzer).

Columns
langnot null VARCHAR
A supported Snowball stemmer language id, e.g. 'english', 'french', 'german'; a valid `lang` value for tokenize(text, lang) and stem(word, lang).
ConstraintsUNIQUE (lang) · PRIMARY KEY (lang)
Examples (5)

List the first few supported Snowball stemmer languages.

SELECT lang FROM tantivy.main.supported_languages ORDER BY lang LIMIT 5;

Check whether a specific language is supported.

SELECT count(*) > 0 AS supported
FROM tantivy.main.supported_languages
WHERE lang = 'english';

Stem the word 'connections' with every supported Snowball stemmer (one row per language from supported_languages) and keep only the languages whose stemmer changes it.

SELECT lang, tantivy.main.stem('connections', lang) AS root
FROM tantivy.main.supported_languages
WHERE tantivy.main.stem('connections', lang) <> 'connections'
ORDER BY lang;
2 more examples
SELECT lang FROM tantivy.main.supported_languages() ORDER BY lang LIMIT 5;
SELECT count(*) > 0 AS supported
FROM tantivy.main.supported_languages()
WHERE lang = 'english';
Link
Scalar functions
bm25_score (doc_text VARCHAR, query VARCHAR) 1 example

Ad-hoc BM25 score of a single document against a query (1-doc index; 0.0 if no match)

Arguments
doc_text VARCHAR
The single document body to score against the query
query VARCHAR
The full-text query whose terms are matched against the document
ReturnsDOUBLE
Example

Ad-hoc BM25 relevance of a single document against a query.

SELECT tantivy.main.bm25_score('the cat sat on the mat', 'cat') AS score;
Link
stem (word VARCHAR, lang VARCHAR) 3 examples

Snowball-stem a single word for the given language (e.g. running → run)

Arguments
word VARCHAR
The single word to reduce to its stem
lang VARCHAR
Snowball stemmer language to stem the word with, e.g. 'english'; call supported_languages() for the valid ids
ReturnsVARCHAR
Examples (3)

Snowball-stem a single English word to its root.

SELECT tantivy.main.stem('running', 'english') AS root;

Stem the word 'connections' with every supported Snowball stemmer (one row per language from supported_languages) and keep only the languages whose stemmer changes it.

SELECT lang, tantivy.main.stem('connections', lang) AS root
FROM tantivy.main.supported_languages
WHERE tantivy.main.stem('connections', lang) <> 'connections'
ORDER BY lang;

Tokenize a sentence (no stemming), then stem each token with stem() to group the word variants under their English Snowball root, most frequent root first.

SELECT tantivy.main.stem(tok, 'english') AS root,
  list(DISTINCT tok ORDER BY tok) AS variants, count(*) AS occurrences
FROM unnest(tantivy.main.tokenize('Runners were running; the runner runs and ran a run.')) AS u(tok)
GROUP BY root
ORDER BY occurrences DESC, root;
Link
tokenize (text VARCHAR, lang VARCHAR) +1 overload 3 examples

Tokenize text into VARCHAR[]; 1-arg form only splits+lowercases (no stemming)

Arguments
text VARCHAR
The text to split into tokens
lang VARCHAR
Snowball stemmer language to apply to each token, e.g. 'english'; call supported_languages() for the valid ids
Overloads
tokenize(text VARCHAR) → VARCHAR[]tokenize(text VARCHAR, lang VARCHAR) → VARCHAR[]
ReturnsVARCHAR[]
Examples (3)

Tokenize text into lowercased word tokens (1-arg form, no stemming).

SELECT tantivy.main.tokenize('Running quickly, CATS!') AS tokens;

Tokenize and Snowball-stem text for a language (2-arg form).

SELECT tantivy.main.tokenize('Running quickly', 'english') AS tokens;

Tokenize a sentence (no stemming), then stem each token with stem() to group the word variants under their English Snowball root, most frequent root first.

SELECT tantivy.main.stem(tok, 'english') AS root,
  list(DISTINCT tok ORDER BY tok) AS variants, count(*) AS occurrences
FROM unnest(tantivy.main.tokenize('Runners were running; the runner runs and ran a run.')) AS u(tok)
GROUP BY root
ORDER BY occurrences DESC, root;
Link
Table functions

Try these queries

Compute the ad-hoc BM25 score of a single document against a query.

SELECT tantivy.main.bm25_score('the cat sat on the mat', 'cat') AS score

Uses bm25_score

Tokenize text into lowercased word tokens (no stemming).

SELECT tantivy.main.tokenize('Running quickly, CATS!') AS tokens

Uses tokenize

Snowball-stem a single word to its root for a language.

SELECT tantivy.main.stem('running', 'english') AS root

Uses stem

List the first few supported Snowball stemmer languages, alphabetically.

SELECT lang FROM tantivy.main.supported_languages ORDER BY lang LIMIT 5

Uses supported_languages

List the first few supported Snowball stemmer languages, alphabetically.

SELECT lang FROM tantivy.main.supported_languages() ORDER BY lang LIMIT 5

Check whether a specific language is supported.

SELECT count(*) > 0 AS supported
FROM tantivy.main.supported_languages()
WHERE lang = 'english'

7 more examples in the Catalog, each listed under the table or function it uses.

Tantivy is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.