I had a difficult time setting up ElasticSearch on both RSpec (CircleCI) and Heroku. The ElasticSearch test cluster was not working on the CircleCI Docker image. Fortunately, one can configure the Circle environment to start with an ElasticSearch process. So, instead of using the test cluster, both my local testing environment and Circle environment use a real ElasticSearch process.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
When a test needs to use ElasticSearch:
1 2 3 4 5 |
|
I ran into issues using ElasticSearch on Heroku when creating an index. Heroku review apps are configurable by defining an app.json
. In the json file, Heroku can spin up an ElasticSearch process.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
The process is running before any Ruby code is executed. The next step is to create the index using postdeploy
. Before creating ActiveRecord objects in the seed.rb
file, create an index with Model.index(force: true)
.