bext/Search powered by TantivyBEXT / 15
Search powered by Tantivy

Your content.
Within reach.

Full-text search, filters, and facets, embedded in the bext engine. Turn your application's content into a searchable local index with Tantivy.

See the integration
FIG. 15 / TANTIVY
From content to discovery.
IN THIS CHAPTER01Local index02Relevance & facets03Server-side queries
01 / Search close to your content

Make what you build discoverable.

Tantivy is a full-text search library written in Rust. bext embeds it in the runtime so your application can query an index on disk, without operating an external search service.

01

Accents stop being a barrier.

Accent and case normalization brings ‘ecran’ together with ‘Écran’. The same analyzer processes both documents and queries.

ecran → Écran
02

Discovery starts as you type.

A prefix on the last term can match a word before it is complete. Guardrails avoid broadening very short terms and numeric identifiers.

repar → réparation
03

A second chance for typos.

When the initial search returns no results, a typo-tolerant fallback can try again. Existing matches take priority over a fuzzy retry.

ipone → iphone
04

Facets that follow the query.

Combine exact filters, counts by value, and numeric ranges. Facets describe the same filtered document set as the search results.

brand · category · price
05

Each site keeps its own index.

Indexes live inside the site's directory. The V8 bridge uses the same access boundary as the site's files and database.

.bext/search/catalog
06

An index that follows your content.

A dedicated indexing tool inserts or updates documents by stable ID. An ID list lets you delete content that has been removed.

insert · update · delete
02 / The flow

Index your content. Search on demand.

01

Your documents

Declare text fields, facets, and numeric values. Export your documents as JSON Lines with a stable ID.

02

The local index

An indexing job writes to Tantivy on the site's disk. The server keeps readers; writes happen outside user requests.

03

Your interface

Query the index from the server. Receive ranked hits, totals, and facet counts to build your own search experience.

03 / In your users' words

Fewer dead ends. More discoveries.

Illustrative examples of supported behavior. Actual results depend on the indexed documents and query.

ecran
Écran OLED

The accent is normalized.

Understand this result

The query and document both go through accent and case normalization.

repar
Guide de réparation

The final word can be incomplete.

Understand this result

An eligible prefix on the last term opens up matching as the user types.

ipone
Coque iPhone

The fallback follows zero results.

Understand this result

Typo tolerance is a second attempt; it does not replace a search that has already found results.

04 / The integration

From schema to search.

Enable the backend on a compatible bext server, create the index, then call the native bridge from a server-side V8 context.

01

Enable the backend

The operator sets BEXT_SEARCH_TANTIVY=1 in the server process configuration. The backend is disabled by default.

02

Prepare and populate the index

Install the bext-search-index tool, declare a schema, and supply your JSON Lines documents. Facet fields must be declared when the index is created.

03

Query from the server

The __search bridge accepts an index name and a JSON query. It returns a JSON string containing hits, totals, and the requested facets.

Read the bext implementation ↗
spec.json · the schema
{
  "text_fields": ["name", "description"],
  "facet_fields": ["category", "brand"],
  "numeric_fields": ["price_cents"]
}
documents.jsonl · a sample document
{"id":"screen-01","name":"Écran OLED","description":"Écran de remplacement","category":"screen","brand":"Demo","price_cents":12900}
terminal · out-of-request indexing
bext-search-index --root /path/to/site \
  --index catalog --spec spec.json \
  --docs documents.jsonl
search.ts · server-side V8 context
declare function __search(index: string, queryJson: string): string;

// In a server-side bext V8 context.
const results = JSON.parse(__search("catalog", JSON.stringify({
  text: "ecran",
  filters: [["category", "screen"]],
  limit: 12,
  offset: 0,
  facets: [
    ["brands", { Terms: { field: "brand", size: 8 } }]
  ]
})));

// results.hits · results.total · results.facets
BEXT × TANTIVY

Search belongs with your application.

Product catalogues, documentation, or a content library: build the interface that works for your users.