دنبال کننده ها

۱۳۹۶ دی ۱۳, چهارشنبه

node.js - Elasticsearch structure for relational DB structure

[ad_1]



I try to sync a postgresql with elasticsearch. I need put data into elasticsearch from 6 tables which are all joined. All data have to be updated on insert, update and delete.



Real DB structure is more complex so here is only a simple DB for demonstration purpose.



Task table



 id | name | founder_id | state_id
-----------------------------------------------------
1 | First task | 1 | 1
2 | Second task | 2 | 3
3 | Third task | 2 | 2
4 | Fourth task | 1 | 1
5 | Fifth task | 2 | 3


State table



 id | name | notification 
------------------------------------------
1 | Todo | false
2 | Progress | false
3 | Done | true


Founder table



 id | name | role | subscribe
--------------------------------------------------
1 | Adam Lee | admin | true
2 | Liam Jobs | user | false


I guess when all data will have to be in one document but I have a problem how to effective solve updates. For example if I update a founder name Adam Lee I will need update it in all documents where founder_id is 1. It could be solve with method updateByQuery but I do not think that is a effective solution.



I use NodeJs and ES6.1.



Have anyone a idea how to design a ES structure for data like this and how to solve a updates?



Thank you.




[ad_2]

لینک منبع