Sha256: fb1969703729ec5da853cde9ce57d1240b84ae2a908f1fb9d7b451e0239c5c53
Contents?: true
Size: 921 Bytes
Versions: 8
Compression:
Stored size: 921 Bytes
Contents
module PgSearch module Features class Trigram < Feature 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
8 entries across 8 versions & 1 rubygems