# How should I store favorited posts?

**URL:** https://discuss.elastic.co/t/how-should-i-store-favorited-posts/199892
**Category:** Elasticsearch
**Created:** [September 17, 2019, 10:57pm UTC](https://discuss.elastic.co/t/how-should-i-store-favorited-posts/199892 "2019-09-17T22:57:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jonjonjon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonjonjon/32/54364_2.png) [@jonjonjon](https://discuss.elastic.co/u/jonjonjon)
#### Post date: [September 17, 2019, 10:57pm UTC](https://discuss.elastic.co/t/how-should-i-store-favorited-posts/199892/1 "2019-09-17T22:57:02Z")

</div>

I have a simple website that allows users "like" posts that other users have submitted.

As a user, I want to be able to search the posts that I have liked.

How should I structure my data, assuming my data looks like this:

```auto
{
    "title": String,
    "description": String
    "author": {
        full_name: String
        user_id: Number
    }
}

```

I do not want to have to maintain an index for every user.

Thanks for your inputs!

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 18, 2019, 12:29am UTC](https://discuss.elastic.co/t/how-should-i-store-favorited-posts/199892/2 "2019-09-18T00:29:57Z")

</div>

Treat it as time-based, event info an just store each like as a single event, with a link to the post in the like event as well.

---

<div class="post-metadata">

### Author: ![jonjonjon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonjonjon/32/54364_2.png) [@jonjonjon](https://discuss.elastic.co/u/jonjonjon)
#### Post date: [September 18, 2019, 12:37am UTC](https://discuss.elastic.co/t/how-should-i-store-favorited-posts/199892/3 "2019-09-18T00:37:03Z")

</div>

Are you referring to a journaling type of data store, such that only GET and INSERT operations are allowed and DELETE and UPDATES are not?

If we do that, then every action that any user has taken to like/unlike a post will be stored.

1. How should I handle the situation where a user has unliked a post and exclude it from the search?
2. This method will accumulate a lot of rows very quickly right?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 18, 2019, 12:40am UTC](https://discuss.elastic.co/t/how-should-i-store-favorited-posts/199892/4 "2019-09-18T00:40:13Z")

</div>

1. Just grab the last event for a given post and user.
2. Potentially, is that a concern though? Ultimately with Elasticsearch you either need to do that or deal with merges when your doing updates, so it's not like either method is "free".

---

<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: [October 16, 2019, 12:40am UTC](https://discuss.elastic.co/t/how-should-i-store-favorited-posts/199892/5 "2019-10-16T00:40:15Z")

</div>

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