Module: Estella::Searchable::ClassMethods

Defined in:
lib/estella/searchable.rb

Instance Method Summary collapse

Instance Method Details

#default_analysis_fieldsObject



69
70
71
# File 'lib/estella/searchable.rb', line 69

def default_analysis_fields
  Estella::Analysis::DEFAULT_FIELDS
end

#index_slugObject

support for mongoid::slug indexes slug attribute by default



62
63
64
65
66
67
# File 'lib/estella/searchable.rb', line 62

def index_slug
  if defined? slug
    indexed_fields.merge!(slug: { type: :keyword })
    indexed_json.merge!(slug: :slug)
  end
end

#searchable(settings = Estella::Analysis::DEFAULT_SETTINGS, &block) ⇒ Object

sets up mappings and settings for index



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/estella/searchable.rb', line 74

def searchable(settings = Estella::Analysis::DEFAULT_SETTINGS, &block)
  Estella::Parser.new(self).instance_eval(&block)
  index_slug
  indexed_fields = @indexed_fields

  settings(settings) do
    mapping do
      indexed_fields.each do |name, opts|
        indexes name, opts.except(:analysis, :using, :factor, :filter, :include_raw)
      end
    end
  end
end