# Real estate property likes and views

**URL:** https://discuss.elastic.co/t/real-estate-property-likes-and-views/314758
**Category:** Elasticsearch
**Created:** [September 20, 2022, 8:57am UTC](https://discuss.elastic.co/t/real-estate-property-likes-and-views/314758 "2022-09-20T08:57:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mohammedsajidkhaleel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohammedsajidkhaleel/32/109402_2.png) [@mohammedsajidkhaleel](https://discuss.elastic.co/u/mohammedsajidkhaleel)
#### Post date: [September 20, 2022, 8:57am UTC](https://discuss.elastic.co/t/real-estate-property-likes-and-views/314758/1 "2022-09-20T08:57:47Z")

</div>

Am working on a property finder project. We are using Elasticsearch to enable flexibility for user to search property. We have option in our app to show whether a user viewed a property before or no while its listed and similarly user can also like a property. What is the best way to store user views and likes data in Elasticsearch. Currently am using Postgres to join the search result with user likes and user views. Now am looking to get rid of this join and accomplish this inside Elasticsearch itself.  
Is it good practice to store the user likes and user views inside a document as an array? Say i will be having likedusers and viewedusers array of user ids. These 2 fields will be updating regularly based on the user activity.

---

<div class="post-metadata">

### Author: ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)
#### Post date: [September 21, 2022, 1:27pm UTC](https://discuss.elastic.co/t/real-estate-property-likes-and-views/314758/2 "2022-09-21T13:27:56Z")

</div>

Internally Elasticsearch does not support partial update of documents.  
Even if using Update API, it is almost the same with delete the existing document and create a new document.

It may cause serious performance problem to store the user likes and user views inside a document . You may need performance test to check if it is acceptable. If the number of viewers and likers per one property is up to tens or thousands, however, it could be acceptable.

Storing view logs and like logs in other indices could be another option.

---

<div class="post-metadata">

### Author: ![mohammedsajidkhaleel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohammedsajidkhaleel/32/109402_2.png) [@mohammedsajidkhaleel](https://discuss.elastic.co/u/mohammedsajidkhaleel)
#### Post date: [September 21, 2022, 1:50pm UTC](https://discuss.elastic.co/t/real-estate-property-likes-and-views/314758/3 "2022-09-21T13:50:06Z")

</div>

Am planning to store listing views and likes in a separate indices. Is there any way to retrieve for each document a boolean field based on the user liked or no from another index in one query.

---

<div class="post-metadata">

### Author: ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)
#### Post date: [September 21, 2022, 2:20pm UTC](https://discuss.elastic.co/t/real-estate-property-likes-and-views/314758/4 "2022-09-21T14:20:06Z")

</div>

I suppose you need separete queries for different indices. What is your query? Are there any requirements?

---

<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 19, 2022, 2:20pm UTC](https://discuss.elastic.co/t/real-estate-property-likes-and-views/314758/5 "2022-10-19T14:20:20Z")

</div>

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