Module: Estella::Searchable::ClassMethods

Defined in:
lib/estella/searchable.rb

Instance Method Summary collapse

Instance Method Details

#default_analysis_fieldsObject



67
68
69
# File 'lib/estella/searchable.rb', line 67

def default_analysis_fields
  Estella::Analysis::DEFAULT_FIELDS
end

#index_slugObject

support for mongoid::slug indexes slug attribute by default



60
61
62
63
64
65
# File 'lib/estella/searchable.rb', line 60

def index_slug
  if defined? slug
    indexed_fields.merge!(slug: { type: :string, index: :not_analyzed })
    indexed_json.merge!(slug: :slug)
  end
end

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

sets up mappings and settings for index



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

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)
      end
    end
  end
end