2
votes

I reainstalled my Bonsai-Elasticsearch addon on Heroku due recent lack of use. It used to work well before but now when I type this in my rails console:

 Lead.__elasticsearch__.create_index! force:true

I get this error:

Elasticsearch::Transport::Transport::Errors::BadRequest ([400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true."}],"type":"illegal_argument_exception","reason":"The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true."},"status":400})

How can I fix this issue?

versions: Rails: 5.2.2 Ruby: 2.6.3 elasticsearch-model: 6.0.0 elasticsearch-rails: 6.0.0

1

1 Answers

1
votes

In Bonsai Elasticsearch we have to create an index at our own.

you can create an index of your post model by

curl -XPUT https://your:[email protected]/posts

You can get your Bonsai Url by

heroku config | grep BONSAI

This is the best tutorial I found you can use it.

More than this you can import your model in elasticsearch by

heroku run bundle exec rake environment elasticsearch:import:model CLASS='Post' FORCE=true

if You face the same error you mentioned above, by running the above command then you should try to change your bonsai & other elasticsearch gems which should be compatible with elasticsearch version.