Module: Elastictastic::BasicDocument::ClassMethods
- Defined in:
- lib/elastictastic/basic_document.rb
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 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_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
135 136 137 |
# File 'lib/elastictastic/basic_document.rb', line 135 def in_index(name_or_index) Scope.new(Elastictastic::Index(name_or_index), self) end |
#mapping ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/elastictastic/basic_document.rb', line 119 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
139 140 141 |
# File 'lib/elastictastic/basic_document.rb', line 139 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
131 132 133 |
# File 'lib/elastictastic/basic_document.rb', line 131 def type name.underscore end |