0

I'm creating app with NodeJs and PostgreSQL and I whant to add ElasticSearch for it But I don't realize

  • how add new data to ElasticSearch
  • how sync my data from PostgreSQL to ElasticSearch

Can someone help me? How add data to ElasticSearch and how sync my data between ElasticSearch and PostgreSQL? Thnq :)

1 Answer 1

2
  • Adding data to ElasticSearch is done by PUTing documents (https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html)

  • Syncing data between postgres and ElasticSearch is a more complicated task. Assuming the data in the postgres tables change, you would need to mark what you indexed in ElasticSearch as indexed or processed, then continue processing. If tuples have a timestamp or incremental ids, then you can process tuples after indexing timestamp or last_processed_id.

You can run a cron job to keep syncing/updating your ElasticSearch indexes, or you can go fancy and write custom triggers in postgres that inserts/updates ElasticSearch documents.

I, personally, would go for triggers since data will be updated/inserted instantly in the ElasticSearch indexes.

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.