Class: ElastomerClient::Client::Percolator
- Inherits:
-
Object
- Object
- ElastomerClient::Client::Percolator
- Defined in:
- lib/elastomer_client/client/percolator.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
Instance Method Summary collapse
-
#create(body, params = {}) ⇒ Object
Create a percolator query.
-
#defaults ⇒ Object
Internal: Returns a Hash containing default parameters.
-
#delete(params = {}) ⇒ Object
Delete a percolator query.
-
#exists?(params = {}) ⇒ Boolean
Checks for the existence of a percolator query.
-
#get(params = {}) ⇒ Object
Gets a percolator query.
-
#initialize(client, index_name, id) ⇒ Percolator
constructor
Create a new Percolator for managing a query.
Constructor Details
#initialize(client, index_name, id) ⇒ Percolator
Create a new Percolator for managing a query.
client - ElastomerClient::Client used for HTTP requests to the server index_name - The index name id - The _id for the query
13 14 15 16 17 |
# File 'lib/elastomer_client/client/percolator.rb', line 13 def initialize(client, index_name, id) @client = client @index_name = client.assert_param_presence(index_name, "index name") @id = client.assert_param_presence(id, "id") end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
19 20 21 |
# File 'lib/elastomer_client/client/percolator.rb', line 19 def client @client end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
19 20 21 |
# File 'lib/elastomer_client/client/percolator.rb', line 19 def id @id end |
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name.
19 20 21 |
# File 'lib/elastomer_client/client/percolator.rb', line 19 def index_name @index_name end |
Instance Method Details
#create(body, params = {}) ⇒ Object
Create a percolator query.
Examples
percolator = $client.index("default-index").percolator "1"
percolator.create query: { match_all: { } }
Returns the response body as a Hash
29 30 31 32 |
# File 'lib/elastomer_client/client/percolator.rb', line 29 def create(body, params = {}) response = client.put("/{index}/percolator/{id}", defaults.merge(params.merge(body:, action: "percolator.create"))) response.body end |
#defaults ⇒ Object
Internal: Returns a Hash containing default parameters.
73 74 75 |
# File 'lib/elastomer_client/client/percolator.rb', line 73 def defaults {index: index_name, id:} end |
#delete(params = {}) ⇒ Object
Delete a percolator query.
Examples
percolator = $client.index("default-index").percolator "1"
percolator.delete
Returns the response body as a Hash
55 56 57 58 |
# File 'lib/elastomer_client/client/percolator.rb', line 55 def delete(params = {}) response = client.delete("/{index}/percolator/{id}", defaults.merge(params.merge(action: "percolator.delete"))) response.body end |
#exists?(params = {}) ⇒ Boolean
Checks for the existence of a percolator query.
Examples
percolator = $client.index("default-index").percolator "1"
percolator.exists?
Returns a boolean
68 69 70 |
# File 'lib/elastomer_client/client/percolator.rb', line 68 def exists?(params = {}) get(params)["found"] end |
#get(params = {}) ⇒ Object
Gets a percolator query.
Examples
percolator = $client.index("default-index").percolator "1"
percolator.get
Returns the response body as a Hash
42 43 44 45 |
# File 'lib/elastomer_client/client/percolator.rb', line 42 def get(params = {}) response = client.get("/{index}/percolator/{id}", defaults.merge(params.merge(action: "percolator.get"))) response.body end |