docs/documentation/query-builder/term/regex.mdx
Regex queries search for terms that follow a pattern. For example, the wildcard pattern key.* finds all terms that start with key.
from paradedb import ParadeDB, Regex
MockItem.objects.filter(
description=ParadeDB(Regex('key.*'))
).values('description', 'rating', 'category')
from sqlalchemy import select
from sqlalchemy.orm import Session
from paradedb.sqlalchemy import search
stmt = (
select(MockItem.description, MockItem.rating, MockItem.category)
.where(search.regex(MockItem.description, "key.*"))
)
with Session(engine) as session:
session.execute(stmt).all()
MockItem.search(:description)
.regex("key.*")
.select(:description, :rating, :category)
ParadeDB supports all regex constructs of the Rust regex crate, with the following exceptions:
+?\bOtherwise, the full syntax of the regex crate is supported, including all Unicode support and relevant flags.
A list of regex flags and grouping options can be found here, which includes:
i)m)During a regex query, ParadeDB doesn't scan through every single word. Instead, it uses a highly optimized structure called a finite state transducer (FST) that makes it possible to jump straight to the matching terms. Even if the index contains millions of words, the regex query only looks at the ones that have a chance of matching, skipping everything else.
This is why the certain regex constructs are not supported -- they are difficult to implement efficiently.