class PgSearch::Features::Trigram
def self.valid_options
def self.valid_options super + [:threshold] end
def conditions
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 normalized_document
def normalized_document Arel::Nodes::Grouping.new(Arel.sql(normalize(document))) end
def normalized_query
def normalized_query sanitized_query = connection.quote(query) Arel.sql(normalize(sanitized_query)) end
def rank
def rank Arel::Nodes::Grouping.new(similarity) end
def similarity
def similarity Arel::Nodes::NamedFunction.new( "similarity", [ normalized_document, normalized_query ] ) end