Skip to content

Commit 89ed402

Browse files
committed
Updated readme for more concise examples.
1 parent e3cd672 commit 89ed402

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A 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

3262
use \Elasticsearch\Client;
3363
use \Zumba\ElastsearchRotator\IndexRotator;
3464

35-
class MyBuilder {
65+
class MySearchIndex {
3666

3767
const INDEX_PREFIX = 'pizza_shops';
3868

0 commit comments

Comments
 (0)