Module: Elasticord::Client::Create
- Defined in:
- lib/elasticord/client/create.rb
Constant Summary collapse
- REFRESH_INDEX_AFTER_CREATE =
true
Class Method Summary collapse
- .build_params(index, type, attributes) ⇒ Object
- .one(elastic_search_client, index, type, attributes = {}) ⇒ Object
Class Method Details
.build_params(index, type, attributes) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/elasticord/client/create.rb', line 18 def build_params(index, type, attributes) params = { type: type, body: attributes, index: index, refresh: REFRESH_INDEX_AFTER_CREATE } params[:id] = attributes[:id] if attributes[:id] params end |
.one(elastic_search_client, index, type, attributes = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/elasticord/client/create.rb', line 8 def one(elastic_search_client, index, type, attributes = {}) params = build_params(index, type, attributes) begin elastic_search_client.index params rescue Elasticsearch::Transport::Transport::Errors::Conflict return false end end |