2

My api generates a feed based on the database records. Elasticsearch consumes this feed using a script. If an item is deleted from my database it will not be in the feed, and therefore the update script does not remove it from elasticsearch.

What is the best approach for handling this case? Should I only soft delete items in the database?

Matt Gardner
  • 527
  • 1
  • 5
  • 12
  • This answer could help: https://stackoverflow.com/questions/34477095/elasticsearch-replication-of-other-system-data/34477639#34477639 – Val Mar 06 '19 at 19:48

1 Answers1

0

3 options that i can think of:

  1. Soft delete like you've suggested
  2. Insert delete id into a separate table so you can use it in your script at consumption time. Truncate the table after that
  3. Query elasticsearch and diff it with your table and delete rows that doesn't exist

I use #2 in my own project

Thinh Pham
  • 402
  • 3
  • 6