elastic_ar_sync 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd13df6ed68262c7b4c23444f09d48a3530ad97e5df6f682f505ec32f9304de1
4
- data.tar.gz: 3b4e0cb0b9c5f0226eaa85aab9d4c68b10a4a1e57c1a435f877a1dbcaa61b257
3
+ metadata.gz: 35a997c8ae813e7a3e34ab3d5dc557e5282322078416597e85608aa34b33c18a
4
+ data.tar.gz: 3f0785cd76f8ca81283119fc6ddc04262f52275645db6986aab779fd1b4c2259
5
5
  SHA512:
6
- metadata.gz: 219487c1c412620a86beabe73e1ef4db107a17d427d69e775ef301e20fe98a24cec1f9af23ee98611a777ba6b05604551ac25fb4e06fbe43b5878e6b020b0be0
7
- data.tar.gz: bc3b782c8f7b8626383b3dee9ec539ad4d7d00d62702c6edfa91eeeab9be91edfe25b3e693fa602b859b85ed52ad746d1d037e8d6d2847119be4770b80ef3436
6
+ metadata.gz: f1ec8db00e1d659cf7884db47befbf49cd4a3b087b37c74ad1352c5510dd2b6667a469a36bad3d620549325c38307dcbcd08c725ae7e42a05ca349183db42bff
7
+ data.tar.gz: 14d0ec670343d14d8d399ad3dcb00bca90987593a545f1d5dad888d1543ebfc180d618e1da95793aaf930c2910f42d2d6b34e50ec0bd8543147ef5371f2b3c07
data/README.md CHANGED
@@ -1,8 +1,90 @@
1
1
  # ElasticArSync
2
- Short description and motivation.
3
-
2
+ This repository contains easy set up modules for RDB and elasticsearch index with Active Record.
3
+ This is based on `gem elasticsearch-rails`.
4
4
  ## Usage
5
- How to use my plugin.
5
+ ### Preparation
6
+ Install `gem sidekiq` and `gem redis-rails` to use Asynchronous processing for your app.
7
+ Install `gem elasticsearch-rails`, `gem elasticsearch-model` and `gem elasticsearch` for your app.
8
+
9
+
10
+ Include module `ElasticArSync::Elastic::Syncable` on your Model class which is inherited ActiveRecord.
11
+
12
+ example below
13
+
14
+ ```ruby
15
+ class XXXXX < ActiveRecord
16
+ include ElasticArSync::Elastic::Syncable
17
+ end
18
+ ```
19
+
20
+ then your Model class is included modules which is for sync model's table with elasticsearch index.
21
+
22
+ when you create new record elasticsearch index save new document in sync.
23
+ update and delete is same as create.
24
+
25
+ this module contains class method `index_setup` to setup index.
26
+
27
+ ### usable methods
28
+ if your Model class included `ElasticArSync::Elastic::Syncable`, it can use class methods below.
29
+
30
+ - index_setup (class method)
31
+ → to setup index to elsticsearch
32
+
33
+ - create_index (class method)
34
+ → to create new index to elasticsearch
35
+
36
+ - delete_index({index_name}) (class method)
37
+ → to delete index. needed argument index name which you delete
38
+
39
+ - import_all_record(index_name) (class method)
40
+ → to sync whole record with elasticsearch
41
+
42
+ - switch_alias(new_index_name) (class method)
43
+ → to switch using index, you needed create more than two index
44
+
45
+ - mapping_list_keys (class method)
46
+ → to get mapping list array of your index
47
+
48
+ - get_aliases (class method)
49
+ → to get aliase list array which you created
50
+
51
+ ### Customize
52
+ if you change process of after commit, you can override instance methods below.
53
+ default is provided by `ElasticArSync::Elastic::Worker::IndexWorker`
54
+
55
+ - document_sync_create
56
+ → for callback of create
57
+
58
+ - document_sync_update
59
+ → for callback of update
60
+
61
+ - document_sync_delete
62
+ → for callback of destroy
63
+
64
+ if you define original mapping of index like type, attribute, etc,
65
+ you can use `index_config` after `include ElasticArSync::Elastic::Syncable`.
66
+
67
+ example below
68
+
69
+ you can override argus `dynamic`, `number_of_shards`, `attr_mappings`.
70
+ especially default mapping is whole attributes of your Model class, so you can customize mapping attributes by overriding attr_mappings.
71
+ ```ruby
72
+ index_config(dynamic: 'false', number_of_shards: 1, attr_mappings: { id: 'integer', name: 'text', birth: 'date' })
73
+ ```
74
+
75
+ if you define your original mapping additionally, you can define like below.
76
+
77
+ tips: just reference here.
78
+
79
+ https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model
80
+ ```ruby
81
+ settings index: { number_of_shards: number_of_shards } do
82
+ mappings do
83
+ indexes key, type: value
84
+ end
85
+ end
86
+ ```
87
+
6
88
 
7
89
  ## Installation
8
90
  Add this line to your application's Gemfile:
@@ -1,3 +1,3 @@
1
1
  module ElasticArSync
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_ar_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - KitakatsuTed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-06 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails