-
Notifications
You must be signed in to change notification settings - Fork 79
Query language
wvanbergen edited this page Aug 16, 2010
·
28 revisions
The query language is simple, but supports several constructs. The query language parser will split the search string into keywords. It will build a query that matches any record that has at least one occurrence of all of these keywords (using the SQL AND
operator) in any of the search fields (using the SQL OR
operator. The query language supports some operators to alter this behavior.
In these example, the name
and description
field of the Person model are search by calling searchable_on :name, :description
.
Willem
:
SELECT * FROM people
WHERE (name LIKE ‘Willem’ OR description LIKE ‘Willem’)
Willem Wes
:
SELECT * FROM people
WHERE (name LIKE (‘Willem’ OR description LIKE ‘Willem’)
AND (name LIKE (‘Wes’ OR description LIKE ‘Wes’)