Method: Tire::Model::Indexing::ClassMethods#mapping
- Defined in:
- lib/tire/model/indexing.rb
#mapping(*args) ⇒ Object
Define the mapping for the corresponding index, telling Elasticsearch how to understand your documents: what type is which property, whether it is analyzed or no, which analyzer to use, etc.
You may pass the top level mapping properties (such as _source
or _all
) as a Hash.
Usage:
class Article
# ...
mapping :_source => { :compress => true } do
indexes :id, :index => :not_analyzed
indexes :title, :analyzer => 'snowball', :boost => 100
indexes :words, :as => 'content.split(/\W/).length'
indexes :comments do
indexes :body
indexes :author do
indexes :name
end
end
# ...
end
end
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/tire/model/indexing.rb', line 56 def mapping(*args) @mapping ||= {} if block_given? @mapping_options = args.pop yield create_elasticsearch_index else @mapping end end |