Sha256: 9e56bcf2b5b9ed459c73c8328242b839f1960ed2b9181ee5005fff84f0fedab1
Contents?: true
Size: 920 Bytes
Versions: 4
Compression:
Stored size: 920 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
4 entries across 4 versions & 1 rubygems