Sha256: 472958e44e8ec13c0e27e5c75deedd37fe21185b8f76fcaa3caffecaf820dc4c

Contents?: true

Size: 608 Bytes

Versions: 6

Compression:

Stored size: 608 Bytes

Contents

module PgSearch
  module Features
    class Trigram < Feature
      def conditions
        Arel::Nodes::Grouping.new(
          Arel::Nodes::InfixOperation.new("%", normalized_document, normalize(query))
        )
      end

      def rank
        Arel::Nodes::Grouping.new(
          Arel::Nodes::NamedFunction.new(
            "similarity",
            [
              normalized_document,
              normalize(query)
            ]
          )
        )
      end

      private

      def normalized_document
        Arel::Nodes::Grouping.new(normalize(Arel.sql(document)))
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pg_search-0.7.0 lib/pg_search/features/trigram.rb
pg_search-0.6.4 lib/pg_search/features/trigram.rb
pg_search-0.6.3 lib/pg_search/features/trigram.rb
pg_search-0.6.2 lib/pg_search/features/trigram.rb
pg_search-0.6.1 lib/pg_search/features/trigram.rb
pg_search-0.6.0 lib/pg_search/features/trigram.rb