Class: Huginn::Searchable::Fuzzy::FullText

Inherits:
Object
  • Object
show all
Defined in:
lib/huginn/searchable/fuzzy.rb

Overview

PostgreSQL full text search over lexemes:

public.f_tsvector(col) @@ plainto_tsquery('portuguese'::regconfig, term)

The column side runs through the configured fts_function (an IMMUTABLE wrapper around to_tsvector that pins the dictionary, created by rails g huginn:fts_indexes) so a GIN tsvector index is usable. The query side uses plainto_tsquery, which ANDs the lexemes of the term and applies stemming — tolerant to morphological variants, blind to typos.

Instance Method Summary collapse

Constructor Details

#initialize(column, value, dictionary: nil) ⇒ FullText

Returns a new instance of FullText.



109
110
111
112
113
# File 'lib/huginn/searchable/fuzzy.rb', line 109

def initialize(column, value, dictionary: nil)
  @column = column
  @value = value.to_s
  @dictionary = dictionary || Huginn.configuration.fts_dictionary
end

Instance Method Details

#predicateObject



115
116
117
# File 'lib/huginn/searchable/fuzzy.rb', line 115

def predicate
  Arel::Nodes::InfixOperation.new("@@", tsvector, query)
end