mysql - RDBMS to Elastic Search -


suppose have 5 tables called groups, posts, groups_posts, post_comments , posts_votes.

groups table has fields: user_id, name , description, posts has fields: user_id , comment

relationship between groups , posts many_2_many each post can belong many groups , each group can contain 0-* posts. table groups_posts does.

post_comments table has fields: text, post_id, user_id, added_at(date), total_comments, total_votes

posts_votes table has fields: post_id, user_id , vote_at(date)

i want model these structure in elastic search. main reason need have quick search popular posts user groups(user can belong 0-* group) specific user last 12 hours based on sum of post comments , post votes amount of time.

could please tell me how map on elastic search indexes.

i think have make decisions.

first, create 1 index each day search 1 index when running queries current day.

since don't have joins in elasticsearch, need aggregate data related data together, e.g. put data related user together, data this:

[   {     "user_id":123,     "groups": [        {          "name":"my group",          "posts_by_user":[ // comments user            {              "content": "foo bar baz",              "votes":5            },            {              "content": "bar baz quux",              "votes": 43            },            ... other posts user in group          ]        },        ... other groups      ]   },   ... other users 

also: read this: https://www.elastic.co/guide/en/elasticsearch/guide/current/modeling-your-data.html


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -