Skip to content

Latest commit

 

History

History
69 lines (44 loc) · 1.66 KB

README.md

File metadata and controls

69 lines (44 loc) · 1.66 KB

Arel Full-Text Search Support Build Status Dependency Status

Adds 'native' full-text search support to Arel.

Usage

In order to produce this query (MySQL Full-Text syntax):

SELECT * FROM people
WHERE MATCH (name) AGAINST ('expression')

You could use this Arel construct:

people = Arel::Table.new(:people)
expr = people[:name].match('expression')

MySQL

Arel Full-Text only supports MySQL currently. Open an issue if you wish to add support to a different database.

Search Modifiers

You can also include search modifiers to further optimize your query.

Boolean Mode

people = Arel::Table.new(:people)
expr = people[:name].match('expression', boolean_mode: true)

Will result in:

SELECT * FROM people
WHERE MATCH (name) AGAINST ('expression' IN BOOLEAN MODE)

Query Expansion

people = Arel::Table.new(:people)
expr = people[:name].match('expression', query_expansion: true)

Will result in:

SELECT * FROM people
WHERE MATCH (name) AGAINST ('expression' WITH QUERY EXPANSION)

Adding Full-Text Index to MySQL

CREATE FULLTEXT INDEX index_id ON table (column);

License

Arel Full-Text is released under a MIT License.

Portions of this software are licensed from Arel, copyrighted 2007-2010 to Nick Kallen, Bryan Helmkamp, Emilio Tagua, Aaron Patterson.