Skip to content
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.

Simple keywords search

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 LIKEWillem’ OR description LIKEWillem’)

Willem Wes:


SELECT * FROM people
WHERE (name LIKE (‘Willem’ OR description LIKEWillem’)
AND (name LIKE (‘Wes’ OR description LIKEWes’)
Clone this wiki locally