-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Feature Request: Add mode = none to whereFullText() for raw to_tsquery
Hi! 👋
I’d like to propose adding support for a “none” mode to the full-text query grammar so that whereFullText() can optionally use raw to_tsquery instead of plainto_tsquery, phraseto_tsquery, or websearch_to_tsquery.
Why this is needed
PostgreSQL’s prefix search (:*) is not recognized by:
plainto_tsqueryphraseto_tsquerywebsearch_to_tsquery
These functions all treat characters like : and * as literal text, not operators.
This means you cannot perform a prefix search like:
to_tsquery('english', 'Ent:*')
when using the current whereFullText() implementation.
Prefix searching is an extremely common use case (autocomplete, partial-name search, etc.), and the only way to get it is through raw to_tsquery.
Proposed Enhancement
In GrammarFullText@whereFullText, allow:
['mode' => 'none']to select:
$mode = 'to_tsquery';Example change:
if (($where['options']['mode'] ?? []) === 'none') {
$mode = 'to_tsquery';
}Example Usage
$q->whereFullText('full_name', "{$prefix}:*", [
'mode' => 'none',
]);Which would compile to:
to_tsvector('english', full_name) @@ to_tsquery('english', 'Ent:*')This gives developers a clean and safe way to use native tsquery syntax—especially prefix operators—without manually writing raw SQL.
Willing to contribute
I’m happy to open a PR implementing this addition if you think it fits the project direction.
Thanks for maintaining this excellent package!