3
3
[ ![ Packagist] ( https://img.shields.io/packagist/v/babenkoivan/scout-elasticsearch-driver.svg )] ( https://packagist.org/packages/babenkoivan/scout-elasticsearch-driver )
4
4
[ ![ Packagist] ( https://img.shields.io/packagist/dt/babenkoivan/scout-elasticsearch-driver.svg )] ( https://packagist.org/packages/babenkoivan/scout-elasticsearch-driver )
5
5
[ ![ Gitter] ( https://img.shields.io/gitter/room/nwjs/nw.js.svg )] ( https://gitter.im/scout-elasticsearch-driver/Lobby )
6
+ [ ![ Donate] ( https://img.shields.io/badge/donate-PayPal-blue.svg )] ( https://www.paypal.me/ivanbabenko )
6
7
7
- :exclamation : The project has a [ chat room] ( https://gitter.im/scout-elasticsearch-driver/Lobby ) on Gitter!
8
+ :coffee : If you like my package, it'd be nice of you [ to buy me a cup of coffee] ( https://www.paypal.me/ivanbabenko ) .
9
+
10
+ :octocat: The project has a [ chat room on Gitter] ( https://gitter.im/scout-elasticsearch-driver/Lobby ) !
11
+
12
+ ---
8
13
9
14
This package offers advanced functionality for searching and filtering data in Elasticsearch.
10
15
Check out its [ features] ( #features ) !
@@ -22,6 +27,7 @@ Check out its [features](#features)!
22
27
* [ Console commands] ( #console-commands )
23
28
* [ Search rules] ( #search-rules )
24
29
* [ Available filters] ( #available-filters )
30
+ * [ Zero downtime migration] ( #zero-downtime-migration )
25
31
* [ Debug] ( #debug )
26
32
27
33
## Tutorial
@@ -36,6 +42,7 @@ There are information about Elasticsearch installation and the package usage exa
36
42
* A possibility to add a new field to an existing mapping [ automatically] ( #configuration ) or using [ the artisan command] ( #console-commands ) .
37
43
* Lots of different ways to implement your search algorithm: using [ search rules] ( #search-rules ) or a [ raw search] ( #usage ) .
38
44
* [ Various filter types] ( #available-filters ) to make a search query more specific.
45
+ * [ Zero downtime migration] ( #zero-downtime-migration ) from an old index to a new index.
39
46
40
47
## Requirements
41
48
@@ -257,6 +264,7 @@ elastic:create-index | `index-configurator` - The index configurator class | Cre
257
264
elastic: update-index | ` index-configurator ` - The index configurator class | Updates settings and mappings of an Elasticsearch index.
258
265
elastic: drop-index | ` index-configurator ` - The index configurator class | Drops an Elasticsearch index.
259
266
elastic: update-mapping | ` model ` - The model class | Updates a model mapping.
267
+ elastic: migrate | ` model ` - The model class, ` target-index ` - The index name to migrate | Migrates model to another index.
260
268
261
269
For detailed description and all available options run ` php artisan help [command] ` in the command line.
262
270
@@ -371,6 +379,29 @@ whereRegexp($field, $value, $flags = 'ALL') | whereRegexp('name.raw', 'A.+') | F
371
379
372
380
In most cases it's better to use raw fields to filter records, i.e. not analyzed fields.
373
381
382
+ ## Zero downtime migration
383
+
384
+ As you might know, you can't change the type of already created field in Elasticsearch.
385
+ The only choice in such case is to create a new index with necessary mapping and import your models into the new index.
386
+ A migration can take quite a long time, so to avoid downtime during the process the driver reads from the old index and writes to the new one.
387
+ As soon as migration is over it starts reading from the new index and removes the old index.
388
+ This is how the artisan ` elastic:migrate ` command works.
389
+
390
+ Before you run the command, make sure that your index configurator uses the ` ScoutElastic\Migratable ` trait.
391
+ If it's not, add the trait and run the artisan ` elastic:update-index ` command using your index configurator class name as an argument:
392
+
393
+ ``` php
394
+ php artisan elastic:update-index App\\MyIndexConfigurator
395
+ ```
396
+
397
+ When you are ready, make changes in the model mapping and run the ` elastic:migrate ` command using the model class as the first argument and desired index name as the second argument:
398
+
399
+ ``` php
400
+ php artisan elastic:migrate App\\MyModel my_index_v2
401
+ ```
402
+
403
+ Note, that if you need just to add new fields in your mapping, use the ` elastic:update-mapping ` command.
404
+
374
405
## Debug
375
406
376
407
There are two methods that can help you to analyze results of a search query:
0 commit comments