Skip to content

Add RegexPhraseQuery, PhrasePrefixQuery, ExistsQuery and EmptyQuery#28

Open
CharlesNg35 wants to merge 2 commits intooxdev03:mainfrom
CharlesNg35:feat/add-query-types
Open

Add RegexPhraseQuery, PhrasePrefixQuery, ExistsQuery and EmptyQuery#28
CharlesNg35 wants to merge 2 commits intooxdev03:mainfrom
CharlesNg35:feat/add-query-types

Conversation

@CharlesNg35
Copy link
Copy Markdown

This PR adds Node.js bindings for four Tantivy query types that are available in tantivy 0.25.0 but were not
yet exposed:

  • RegexPhraseQuery — phrase search where each term is a regex pattern, with slop and max_expansions support
  • PhrasePrefixQuery — phrase search where the last term is treated as a prefix, with max_expansions support
  • ExistsQuery — matches all documents that have a non-null value in a given field
  • EmptyQuery — matches no documents (useful as a placeholder/default)

Changes

  • src/query.rs — Rust implementations for all four query types
  • index.d.ts — TypeScript declarations
  • test/index.spec.ts — Tests for the new queries (including error cases)

Usage examples

  // Fuzzy phrase matching: "apocal*" near "10" with slop
  Query.regexPhraseQuery(schema, 'content', ['apocal.*', '10'], 25)

  // Autocomplete: "apocalypse di" → matches "apocalypse divine", "apocalypse dix"
  Query.phrasePrefixQuery(schema, 'content', ['apocalypse', 'di'])

  // Filter: only documents that have a value in "category"
  Query.existsQuery(schema, 'category')

  // No-op placeholder
  Query.emptyQuery()

Note
This code was generated with the help of Claude Claude. Please review the Rust implementations.

Closes #27

…uery bindings

Expose four additional Tantivy query types that were missing from the Node.js bindings:

- RegexPhraseQuery — phrase search with regex patterns and slop support
- PhrasePrefixQuery — phrase search with prefix matching on the last term
- ExistsQuery — filter documents that have a value in a given field
- EmptyQuery — no-op query that matches nothing

Includes TypeScript declarations and tests.

Closes oxdev03#27
@CharlesNg35 CharlesNg35 changed the title feat: add RegexPhraseQuery, PhrasePrefixQuery, ExistsQuery and EmptyQuery bindings Add RegexPhraseQuery, PhrasePrefixQuery, ExistsQuery and EmptyQuery Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add RegexPhraseQuery support

1 participant