File tree Expand file tree Collapse file tree 1 file changed +32
-2
lines changed Expand file tree Collapse file tree 1 file changed +32
-2
lines changed Original file line number Diff line number Diff line change 22
33A library to enable you to safely rotate indexes with no downtime to end users.
44
5- [ ![ Build Status] ( https://travis-ci.com /zumba/elasticsearch-index-rotator.svg?token=zXFxge7zUgReaCncg1CL& branch=master )] ( https://travis-ci.com /zumba/elasticsearch-index-rotator )
5+ [ ![ Build Status] ( https://travis-ci.org /zumba/elasticsearch-index-rotator.svg?branch=master )] ( https://travis-ci.org /zumba/elasticsearch-index-rotator )
66
77### Why would I use this?
88
@@ -26,13 +26,43 @@ composer require zumba\elasticsearch-index-rotator
2626
2727## Usage
2828
29+ #### Example Search
30+
31+ ``` php
32+ <?php
33+
34+ $client = new \Elasticsearch\Client();
35+ $indexRotator = new \Zumba\ElasticsearchRotator\IndexRotator($client, 'pizza_shops');
36+ $client->search([
37+ 'index' => $indexRotator->getPrimaryIndex(), // Get the current primary!
38+ 'type' => 'shop',
39+ 'body' => [] //...
40+ ]);
41+ ```
42+
43+ #### Example Build
44+
45+ ``` php
46+ <?php
47+
48+ $client = new \Elasticsearch\Client();
49+ $indexRotator = new IndexRotator($client, 'pizza_shops');
50+ $newlyBuiltIndexName = $this->buildIndex($client);
51+ $indexRotator->copyPrimaryIndexToSecondary();
52+ $indexRotator->setPrimaryIndex($newlyBuiltIndexName);
53+ // optionally remove the old index right now
54+ $indexRotator->deleteSecondaryIndexes();
55+ ```
56+
57+ #### All together
58+
2959``` php
3060<?php
3161
3262use \Elasticsearch\Client;
3363use \Zumba\ElastsearchRotator\IndexRotator;
3464
35- class MyBuilder {
65+ class MySearchIndex {
3666
3767 const INDEX_PREFIX = 'pizza_shops';
3868
You can’t perform that action at this time.
0 commit comments