Skip to content

Support suffix and wildcard matching (currently prefix-only) #26

Description

@micheleriva

Summary

zbsearch currently supports prefix matching (search-as-you-type) via the radix tree, but has no way to match by suffix ("ends-with") or by an infix/wildcard pattern. Several competitors offer this:

  • Fuse.js$ (suffix-exact) and !$ (not-suffix) extended-search operators
  • FlexSearchreverse/bidirectional tokenizer for suffix matching
  • Lunr — wildcard queries: *oo (suffix), f*o (infix), foo* (prefix)

Motivation

Matching the tail of a term (file extensions like .js, suffix-heavy morphology, part numbers/SKUs) is impossible today without indexing tricks on the user's side.

Proposed direction

  • Consider a reverse radix index (à la FlexSearch reverse) to make suffix lookups cheap, opt-in per field to avoid the memory cost.
  • Alternatively/additionally, support a limited wildcard syntax (*term, te*rm) in the query, expanded against the radix tree.

Notes / trade-offs

  • Suffix indexing roughly doubles the string index memory for fields it's enabled on; should be opt-in.
  • Infix/full-substring matching is the most expensive; scope carefully.

Related

Part of a competitive feature-gap review vs Fuse.js, MiniSearch, FlexSearch, Lunr.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions