elastic_ar_sync 0.1.1 → 0.1.2
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 +4 -4
- data/lib/elastic_ar_sync/elastic/syncable.rb +20 -4
- data/lib/elastic_ar_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5064e37715c757321f546ba33bba3804a074ea847abacbd62e2b8c8b97bf650
|
4
|
+
data.tar.gz: 2cc2dd0be8de3705775eed297c0e9b4a1464a73f7ae93f68801b6155bd439746
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f1d68abc5470a9e7fe8dcea07b20532ace4d9307d20fac684191daff36bfe16e6cd8e77ea3d82680f158c1e685fcb4b25f596d397e0f308ed7c9e75dbf3d100
|
7
|
+
data.tar.gz: 505adfb0db637e619873cb31c54c07d75fa5a7f5056492cf3fc34509dff7592a1d6ee86a111aa48a8ef732a142d5299a7728819b75aa0be81085df8145cc2cbf
|
@@ -67,24 +67,32 @@ module ElasticArSync
|
|
67
67
|
ElasticArSync::Elastic::Services::IndexHandler.new(self).switch_alias(alias_name: index_name, new_index_name: new_index_name)
|
68
68
|
end
|
69
69
|
|
70
|
-
def index_config(dynamic: 'false',
|
71
|
-
|
70
|
+
def index_config(dynamic: 'false', override_settings: {}, attr_mappings: default_index_mapping, override_mappings: {})
|
71
|
+
attr_mappings.merge!(override_mappings) if override_mappings.present?
|
72
|
+
|
73
|
+
settings default_index_setting.merge!(override_settings) do
|
72
74
|
# ES6からStringが使えないのでtextかkeywordにする。
|
73
75
|
mappings dynamic: dynamic do
|
74
76
|
attr_mappings.each do |key, value|
|
75
|
-
|
77
|
+
next unless value.is_a?(Hash)
|
78
|
+
|
79
|
+
indexes key, value
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
85
|
+
def default_index_setting
|
86
|
+
{ index: { number_of_shards: 1 } }
|
87
|
+
end
|
88
|
+
|
81
89
|
def default_index_mapping
|
82
90
|
mapping = {}
|
83
91
|
attribute_types.each do |attribute, active_model_type|
|
84
92
|
type = active_model_type.type
|
85
93
|
type = :text if (active_model_type.type.to_sym == :string) || (type == :integer && defined_enums.symbolize_keys.keys.include?(attribute.to_sym))
|
86
94
|
type = :date if active_model_type.type == :datetime
|
87
|
-
mapping[attribute.to_sym] = type
|
95
|
+
mapping[attribute.to_sym] = { type: type }
|
88
96
|
end
|
89
97
|
mapping
|
90
98
|
end
|
@@ -100,6 +108,14 @@ module ElasticArSync
|
|
100
108
|
raise Elasticsearch::Transport::Transport::Errors::NotFound, "インデックスがありません alias_name: #{alias_name}"
|
101
109
|
end
|
102
110
|
end
|
111
|
+
|
112
|
+
def current_index
|
113
|
+
get_aliases.select { |_, value| value["aliases"].present? }.keys.first
|
114
|
+
end
|
115
|
+
|
116
|
+
def current_mapping
|
117
|
+
__elasticsearch__.client.indices.get_mapping[current_index]["mappings"]["_doc"]["properties"]
|
118
|
+
end
|
103
119
|
end
|
104
120
|
end
|
105
121
|
end
|