Skip to content

Commit 00a42c8

Browse files
committed
update readme
1 parent 680289f commit 00a42c8

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ end
8181
* [`:trigram` (Trigram search)](#trigram-trigram-search)
8282
* [`:threshold`](#threshold)
8383
* [`:word_similarity`](#word_similarity)
84+
* [`:ilike` (Basic Search)](#ilike-basic-search)
8485
* [Limiting Fields When Combining Features](#limiting-fields-when-combining-features)
8586
* [Ignoring accent marks](#ignoring-accent-marks)
8687
* [Using tsvector columns](#using-tsvector-columns)
@@ -548,7 +549,7 @@ search techniques.
548549
```ruby
549550
class Beer < ActiveRecord::Base
550551
include PgSearch::Model
551-
pg_search_scope :search_name, against: :name, using: [:tsearch, :trigram, :dmetaphone]
552+
pg_search_scope :search_name, against: :name, using: [:tsearch, :trigram, :dmetaphone, :ilike]
552553
end
553554
```
554555

@@ -562,7 +563,8 @@ class Beer < ActiveRecord::Base
562563
using: {
563564
:trigram => {},
564565
:dmetaphone => {},
565-
:tsearch => { :prefix => true }
566+
:tsearch => { :prefix => true },
567+
:ilike => {}
566568
}
567569
end
568570
```
@@ -573,6 +575,7 @@ The currently implemented features are
573575
* :trigram - [Trigram search](http://www.postgresql.org/docs/current/static/pgtrgm.html), which
574576
requires the trigram extension
575577
* :dmetaphone - [Double Metaphone search](http://www.postgresql.org/docs/current/static/fuzzystrmatch.html#AEN177521), which requires the fuzzystrmatch extension
578+
* :iliek - Basic search using built in ilike operator
576579

577580

578581
#### :tsearch (Full Text Search)
@@ -976,6 +979,22 @@ Sentence.similarity_like("word") # => []
976979
Sentence.word_similarity_like("word") # => [sentence]
977980
```
978981

982+
### :ilike (Basic Search)
983+
984+
Basic search using ilike. This will look for anything containing an exact match, ie `%QUERY%`. This is useful in situations where you are looking for a substring.
985+
986+
```ruby
987+
class Company < ActiveRecord::Base
988+
include PgSearch::Model
989+
pg_search_scope :find_substring,
990+
against: :name,
991+
using: :ilike
992+
end
993+
994+
macrohard = Company.create! name: "MacroHard"
995+
Website.find_substring("hard") # => [macrohard]
996+
```
997+
979998
### Limiting Fields When Combining Features
980999

9811000
Sometimes when doing queries combining different features you

0 commit comments

Comments
 (0)