Module: Elastictastic::BasicDocument::ClassMethods
- Defined in:
- lib/elastictastic/basic_document.rb
Instance Attribute Summary collapse
-
#default_index ⇒ Object
writeonly
Sets the attribute default_index.
Instance Method Summary collapse
-
#any? ⇒ TrueClass, FalseClass
True if there are documents of this type in the default index.
-
#count ⇒ Fixnum
The number of documents of this type in the default index.
-
#destroy_all ⇒ Object
Destroy all instances of this class in the default index.
-
#empty? ⇒ TrueClass, FalseClass
True if there are no documents of this type in the default index.
-
#find_each(batch_options = {}) {|document, hit| ... } ⇒ Enumerator
Iterate over all documents in the default index, retrieving documents in batches using a cursor, but yielding them one by one.
-
#find_in_batches(batch_options = {}) {|batch| ... } ⇒ Enumerator
Retrieve all documents in the default index, yielding them in batches.
-
#first ⇒ Document
The “first” document in the index (“first” is undefined).
- #in_index(name_or_index) ⇒ Object
- #mapping ⇒ Object
- #scoped(params) ⇒ Object
-
#sync_mapping ⇒ Object
Push the mapping defined in this class to ElasticSearch.
- #type ⇒ Object
Instance Attribute Details
#default_index=(value) ⇒ Object
Sets the attribute default_index
119 120 121 |
# File 'lib/elastictastic/basic_document.rb', line 119 def default_index=(value) @default_index = value end |
Instance Method Details
#any? ⇒ TrueClass, FalseClass
Returns True if there are documents of this type in the default index.
113 114 115 116 117 |
# File 'lib/elastictastic/basic_document.rb', line 113 delegate :find, :destroy, :destroy_all, :sync_mapping, :inspect, :find_each, :find_in_batches, :first, :count, :empty?, :any?, :all, :query, :filter, :from, :size, :sort, :highlight, :fields, :script_fields, :preference, :facets, :routing, :to => :current_scope |
#count ⇒ Fixnum
Returns The number of documents of this type in the default index.
|
# File 'lib/elastictastic/basic_document.rb', line 93
|
#destroy_all ⇒ Object
Destroy all instances of this class in the default index
|
# File 'lib/elastictastic/basic_document.rb', line 47
|
#empty? ⇒ TrueClass, FalseClass
Returns True if there are no documents of this type in the default index.
|
# File 'lib/elastictastic/basic_document.rb', line 99
|
#find_each(batch_options = {}) {|document, hit| ... } ⇒ Enumerator
Iterate over all documents in the default index, retrieving documents in batches using a cursor, but yielding them one by one.
|
# File 'lib/elastictastic/basic_document.rb', line 61
|
#find_in_batches(batch_options = {}) {|batch| ... } ⇒ Enumerator
Retrieve all documents in the default index, yielding them in batches.
|
# File 'lib/elastictastic/basic_document.rb', line 74
|
#first ⇒ Document
Returns The “first” document in the index (“first” is undefined).
|
# File 'lib/elastictastic/basic_document.rb', line 86
|
#in_index(name_or_index) ⇒ Object
137 138 139 |
# File 'lib/elastictastic/basic_document.rb', line 137 def in_index(name_or_index) Scope.new(Elastictastic::Index(name_or_index), self) end |
#mapping ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/elastictastic/basic_document.rb', line 121 def mapping mapping_for_type = { 'properties' => properties } mapping_for_type['_boost'] = @_boost if @_boost if @_routing_field mapping_for_type['_routing'] = { 'path' => @_routing_field.to_s, 'required' => @_routing_required } end { type => mapping_for_type } end |
#scoped(params) ⇒ Object
141 142 143 |
# File 'lib/elastictastic/basic_document.rb', line 141 def scoped(params) current_scope.scoped(params) end |
#sync_mapping ⇒ Object
Push the mapping defined in this class to ElasticSearch. Be sure to do this before saving instances of your class, or after making changes to the class’s mapping (e.g. adding fields)
|
# File 'lib/elastictastic/basic_document.rb', line 53
|
#type ⇒ Object
133 134 135 |
# File 'lib/elastictastic/basic_document.rb', line 133 def type name.underscore end |