README.md in elasticsearch-extensions-0.0.20 vs README.md in elasticsearch-extensions-0.0.21

- old
+ new

@@ -21,9 +21,88 @@ rake install ## Extensions +### Backup + +Backup Elasticsearch indices as flat JSON files on the disk via integration +with the [_Backup_](http://backup.github.io/backup/v4/) gem. + +Use the Backup gem's DSL to configure the backup: + + require 'elasticsearch/extensions/backup' + + Model.new(:elasticsearch_backup, 'Elasticsearch') do + + database Elasticsearch do |db| + db.url = 'http://localhost:9200' + db.indices = 'test' + end + + store_with Local do |local| + local.path = '/tmp/backups' + end + + compress_with Gzip + end + +Perform the backup with the Backup gem's command line utility: + + $ backup perform -t elasticsearch_backup + +See more information in the [`Backup::Database::Elasticsearch`](lib/extensions/backup.rb) +class documentation. + +### Reindex + +Copy documents from one index and cluster into another one, for example for purposes of changing +the settings and mappings of the index. + +**NOTE:** Elasticsearch natively supports re-indexing since version 2.3. This extension is useful + when you need the feature on older versions. + +When the extension is loaded together with the +[Ruby client for Elasticsearch](../elasticsearch/README.md), +a `reindex` method is added to the client: + + require 'elasticsearch' + require 'elasticsearch/extensions/reindex' + + client = Elasticsearch::Client.new + target_client = Elasticsearch::Client.new url: 'http://localhost:9250', log: true + + client.index index: 'test', type: 'd', body: { title: 'foo' } + + client.reindex source: { index: 'test' }, + target: { index: 'test', client: target_client }, + transform: lambda { |doc| doc['_source']['title'].upcase! }, + refresh: true + # => { errors: 0 } + + target_client.search index: 'test' + # => ... hits ... "title"=>"FOO" + +The method takes similar arguments as the core API +[`reindex`](http://www.rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Actions#reindex-instance_method) +method. + +You can also use the `Reindex` class directly: + + require 'elasticsearch' + require 'elasticsearch/extensions/reindex' + + client = Elasticsearch::Client.new + + reindex = Elasticsearch::Extensions::Reindex.new \ + source: { index: 'test', client: client }, + target: { index: 'test-copy' } + + reindex.perform + +See more information in the [`Elasticsearch::Extensions::Reindex::Reindex`](lib/extensions/reindex.rb) +class documentation. + ### ANSI Colorize and format selected Elasticsearch response parts in terminal: Display formatted search results: