0

I am trying to insert data using elastic search PUT with the Elasticsearch gem in ruby, but I am getting method not found error.

Here is the sample code:

 def self.insert_data_in_es
   name = (here I am giving the url)
   body = (actual data)
   Elasticsearch::API::Indices::Actions.put_template(name: name, body: 
   body)

end

Error :
NoMethodError: undefined method `put_template' for Elasticsearch::API::Indices::Actions:Module

Is there any other way of doing it?

1 Answer 1

1

You are getting this error because Actions is just a module, included in Elasticsearch::API::Indices::IndicesClient.

You should initialize your client and call it like this:

client.indicies.put_template(args)

Anyways, I highly recommend you to have a look at chewy. It's very cool elasticsearch gem, maintained by toptal.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.