module Elasticsearch::Model::Naming::ClassMethods

Public Instance Methods

document_type(name=nil) click to toggle source

Get or set the document type

@example Set the document type for the ‘Article` model

class Article
  document_type "my-article"
end

@example Directly set the document type for the ‘Article` model

Article.document_type "my-article"
# File lib/elasticsearch/model/naming.rb, line 47
def document_type name=nil
  @document_type = name || @document_type || self.model_name.element
end
document_type=(name) click to toggle source

Set the document type

@see document_type

# File lib/elasticsearch/model/naming.rb, line 56
def document_type=(name)
  @document_type = name
end
index_name(name=nil) click to toggle source

Get or set the name of the index

@example Set the index name for the ‘Article` model

class Article
  index_name "articles-#{Rails.env}"
end

@example Directly set the index name for the ‘Article` model

Article.index_name "articles-#{Rails.env}"

TODO: Dynamic names a la Tire – ‘Article.index_name { “articles-#{Time.now.year}” }`

# File lib/elasticsearch/model/naming.rb, line 24
def index_name name=nil
  @index_name = name || @index_name || self.model_name.collection.gsub(/\//, '-')
end
index_name=(name) click to toggle source

Set the index name

@see index_name

# File lib/elasticsearch/model/naming.rb, line 31
def index_name=(name)
  @index_name = name
end