You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[MODEL] Added mappings and settings method to set up index options for the model
Example:
class Article
mapping dynamic: 'strict' do
indexes :foo do
indexes :bar
end
indexes :baz
end
end
> Article.mapping.to_hash
# => {:article =>
{:dynamic=>"strict",
:properties=>
{:foo=>{:type=>"object", :properties=>{:bar=>{:type=>"string"}}},
:baz=>{:type=>"string"}}}}
When the model would define the `mapping(s)` or `settings` method, access
the interface through the `__elasticsearch__` proxy:
class Article
__elasticsearch__ do
mapping dynamic: 'strict' do
indexes :foo do
indexes :bar
end
indexes :baz
end
end
end
Of course, you can call the method directly:
Article.mapping(dynamic: 'strict') { indexes :foo, type: 'long' }
> Article.mapping.to_hash
{ :dynamic=>"strict",
:properties=>{:foo=>{:type=>"long"}}}}
Copy file name to clipboardExpand all lines: elasticsearch-model/lib/elasticsearch/model/indexing.rb
+151-2
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,162 @@
1
1
moduleElasticsearch
2
2
moduleModel
3
+
4
+
# This module provides the necessary support to set up index options (mappings, settings)
5
+
# as well as instance methods to create, update or delete documents in the index.
6
+
#
3
7
moduleIndexing
4
8
9
+
# Wraps the [index settings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-configuration.html#configuration-index-settings)
10
+
#
11
+
classSettings
12
+
attr_accessor:settings
13
+
14
+
definitialize(settings={})
15
+
@settings=settings
16
+
end
17
+
18
+
defto_hash
19
+
@settings
20
+
end
21
+
22
+
defas_json(options={})
23
+
to_hash
24
+
end
25
+
end
26
+
27
+
# Wraps the [index mappings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping.html)
0 commit comments