# Storing user based events in elasticsearch

**URL:** https://discuss.elastic.co/t/storing-user-based-events-in-elasticsearch/173387
**Category:** Elasticsearch
**Created:** [March 21, 2019, 7:49pm UTC](https://discuss.elastic.co/t/storing-user-based-events-in-elasticsearch/173387 "2019-03-21T19:49:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Bharathi\_Kannan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bharathi_kannan/32/42377_2.png) [@Bharathi\_Kannan](https://discuss.elastic.co/u/Bharathi_Kannan)
#### Post date: [March 21, 2019, 7:49pm UTC](https://discuss.elastic.co/t/storing-user-based-events-in-elasticsearch/173387/1 "2019-03-21T19:49:54Z")

</div>

Hi,

We are building a events data store on top of elasticsearch. Our goal is to provide real-time analytics with advanced segmentation on top of users & events. Our entities are

1. Users or Visitors
2. Events (Which is performed by Users, which will be above 100 - 1000)

Example:

> {  
> "first\_name": "John",  
> "email": "[john@es.com](mailto:john@es.com)",  
> "country": "US",  
> "user\_id": 100  
> }

> {  
> "event\_name": "Add To Cart",  
> "user\_id": 100,  
> "product\_name": "IPhone X"  
> }

I tried 2 options

1. Nested Documents, a concern is user attributes will not be modified frequently. But, events will be performed very frequently. Let's say a user will perform 1000+ events, so the same doc will be updated more than 1000 times.

2. Parent-Child Relationship, not satisfying segmentation

Possible Queries:

1. Give me the user ids, who is in the US and performed "Add To Cart" & product name is "iPhone X"

With nested documents, it is working out well. But parent-child, I couldn't able to perform the search on parent & child at the same time.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 18, 2019, 7:51pm UTC](https://discuss.elastic.co/t/storing-user-based-events-in-elasticsearch/173387/2 "2019-04-18T19:51:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
