docs/documentation/query-builder/phrase/phrase-prefix.mdx
Phrase prefix identifies documents containing a phrase followed by a term prefix.
<CodeGroup> ```sql SQL SELECT description, rating, category FROM mock_items WHERE description @@@ pdb.phrase_prefix(ARRAY['running', 'sh']); ```from paradedb import ParadeDB, PhrasePrefix
MockItem.objects.filter(
description=ParadeDB(PhrasePrefix('running', 'sh'))
).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.phrase_prefix(MockItem.description, ["running", "sh"]))
)
with Session(engine) as session:
session.execute(stmt).all()
MockItem.search(:description)
.phrase_prefix("running", "sh")
.select(:description, :rating, :category)
Expanding a prefix might lead to thousands of matching terms, which impacts search times.
With max_expansions, the prefix term is expanded to at most max_expansions terms
in lexicographic order. For instance, if sh matches shall, share, shoe, and shore but max_expansions is set to 3,
sh will only be expanded to shall, share, and shoe.