@@ -23,6 +23,52 @@ or install it from a source code checkout:
23
23
24
24
## Extensions
25
25
26
+ ### Reindex
27
+
28
+ Copy documents from one index and cluster into another one, for example for purposes of changing
29
+ the settings and mappings of the index.
30
+
31
+ ** NOTE:** Elasticsearch natively supports re-indexing since version 2.3. This extension is useful
32
+ when you need the feature on older versions.
33
+
34
+ When the extension is loaded together with the
35
+ [ Ruby client for Elasticsearch] ( ../elasticsearch/README.md ) ,
36
+ a ` reindex ` method is added to the client:
37
+
38
+ require 'elasticsearch'
39
+ require 'elasticsearch/extensions/reindex'
40
+
41
+ client = Elasticsearch::Client.new
42
+ target_client = Elasticsearch::Client.new url: 'http://localhost:9250', log: true
43
+
44
+ client.index index: 'test', type: 'd', body: { title: 'foo' }
45
+
46
+ client.reindex source: { index: 'test' },
47
+ target: { index: 'test', client: target_client },
48
+ transform: lambda { |doc| doc['_source']['title'].upcase! },
49
+ refresh: true
50
+ # => { errors: 0 }
51
+
52
+ target_client.search index: 'test'
53
+ # => ... hits ... "title"=>"FOO"
54
+
55
+ The method takes similar arguments as the core API
56
+ [ ` reindex ` ] ( http://www.rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Actions#reindex-instance_method )
57
+ method.
58
+
59
+ You can also use the ` Reindex ` class directly:
60
+
61
+ require 'elasticsearch'
62
+ require 'elasticsearch/extensions/reindex'
63
+
64
+ client = Elasticsearch::Client.new
65
+
66
+ reindex = Elasticsearch::Extensions::Reindex.new \
67
+ source: { index: 'test', client: client },
68
+ target: { index: 'test-copy' }
69
+
70
+ reindex.perform
71
+
26
72
### ANSI
27
73
28
74
Colorize and format selected Elasticsearch response parts in terminal:
0 commit comments