Advise needed to structure data in elasticsearch for search and updates

Hello,

I have two tables in db (videos and user_views), now planning to move there
data to elsticseacrch,

I need an advise how to structure data in elasticsearch for best search and
analytics.

Following are the type of results, I potentially want to get from
elasticsearch

  1. For Search Query

SELECT a.id, a.video_title , (SELECT SUM(view_count) FROM user_views b
WHERE b.video_id = a.id) FROM videos a;
OR
SELECT a.* , (SELECT SUM(view_count) FROM user_views b WHERE b.video_id =
a.id) FROM videos a;

I can get results by first query videos in elaticssearch and do a term
stats facet on video id and merge there results.

What's the best way to get these results from elasticsearch?
*
*
2. For update

UPDATE user_views SET view_count = view_count+1 WHERE user = someUserId;

To update the reusult in elasticsearch

curl -XPOST 'localhost:9200/index/user_views /1/_update' -d '{
"script" : "ctx._source.view_count += count",
"params" : {
"count" :1
}
}'

How to put the userId where clause? Is there any other way to update
records in elasticsearch?

Kindy suggest

Thanks
-Maaz

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.