0

hope you are fine!

I have implement elasticsearch Locally & also in production on Heroku but I face a problem on Heroku that when I create an index by

curl -XPUT https://your:bonsai@url-here.us-east-1.bonsai.io/blogs-blogs

I can search from the records which are newly added after making the index but not able to search from the records which I save before this index.

Humayun Naseer
  • 440
  • 7
  • 18
  • Where did you "add" your records before your create your index ? – Jaycreation Dec 15 '20 at 06:05
  • i save my record in my Postgres database on Heroku using Postgres addons – Humayun Naseer Dec 15 '20 at 08:26
  • so you have to load your history in Elasticsearch. Usually frameworks add trigger on an entity Create/Update/Delete. But you have to Batch insert the history. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html – Jaycreation Dec 15 '20 at 08:32
  • it's mean there is no other way first I have to delete my records then add them again by batch insertion? – Humayun Naseer Dec 15 '20 at 08:37
  • Of course you don't have to delete your records from postgres. You juste have to write a script to init your history. If it's to complicated, just touch all your data with your entity, but it will update your updated_at date also. So you should just write your initialisation script. – Jaycreation Dec 15 '20 at 08:42
  • thankyou @Jaycreation I'll try this & Thankyou for the help <3 – Humayun Naseer Dec 15 '20 at 08:49

1 Answers1

0

If you want to import your models in elasticsearch you can easily done by the following line

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

But make sure your Bonsai and other Es gems should be compatible with elasticsearch.

Humayun Naseer
  • 440
  • 7
  • 18