-
Notifications
You must be signed in to change notification settings - Fork 79
Free Text
The master branch of scoped_search now implements a full text searching on postgresql. This allows for indexes to be used during searching which can increase query speed to near sphinx / lucene levels.
A free text search for “friend” will also find related words such as friends and friendly.
The definition for using the free text feature is the following (where english is the locale).
scoped_search on: :name, full_text_search: :english
To gain the speed benefit an index must be manually created:
CREATE INDEX widgets_name_full_text_search ON widgets USING gin(to_tsvector(‘english’, name));
Read more about creating full text indexes here:
http://www.postgresql.org/docs/8.3/static/textsearch-tables.html#TEXTSEARCH-TABLES-SEARCH
This replaces ILIKE as the query used, however, it is not a drop in replacement for ILIKE in functionality. This performs more complex matching but at the same time doesn’t do things like matching substrings.
If database vendor is changed it will just be ignored as expected. Only thing is <8.3 postgresql does not support this. Although that is really old now and this is an opt in feature.