Sha256: 19f80c7fd22a19cb8372fa124ab4e8552608614a10152d321d8f2aae3b5b54cb
Contents?: true
Size: 989 Bytes
Versions: 9
Compression:
Stored size: 989 Bytes
Contents
module PgSearch module Features class Trigram < Feature def self.valid_options super + [:threshold] end def conditions if options[:threshold] Arel::Nodes::Grouping.new( similarity.gteq(options[:threshold]) ) else Arel::Nodes::Grouping.new( Arel::Nodes::InfixOperation.new("%", normalized_document, normalized_query) ) end end def rank Arel::Nodes::Grouping.new(similarity) end private def similarity Arel::Nodes::NamedFunction.new( "similarity", [ normalized_document, normalized_query ] ) end def normalized_document Arel::Nodes::Grouping.new(Arel.sql(normalize(document))) end def normalized_query sanitized_query = connection.quote(query) Arel.sql(normalize(sanitized_query)) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems