# Design approach for counting friends unique category counts

**URL:** <https://discuss.elastic.co/t/design-approach-for-counting-friends-unique-category-counts/164667>\
**Category:** Elasticsearch\
**Created:** [January 17, 2019, 3:28pm UTC](https://discuss.elastic.co/t/design-approach-for-counting-friends-unique-category-counts/164667 "2019-01-17T15:28:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bujji1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bujji1/32/112962_2.png) [@Bujji1](https://discuss.elastic.co/u/Bujji1)\
**Post date:** [January 17, 2019, 3:28pm UTC](https://discuss.elastic.co/t/design-approach-for-counting-friends-unique-category-counts/164667/1 "2019-01-17T15:28:12Z")

</div>

Hello All ,

I just started using Elastic Search and It is simply awesome . I am looking for a best design approach for my case .

In the below Index , Friends and all categories are numeric arrays . I can have up to 5000 friends and categories also arrays and they can have max 15 for each category . If I have 5000 friends and If my one of the category changes ( for example category 1 changes ) I have to count "Friends Category1 counts" for my all 5000 friends and update their counts .

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bd8e6ba1bf50f7378915e81cb5de3f211ab7babb.png)

Is there any way I can use Painless script and do it with one call ..? Or please guide me the best approach to handle this case

I use Nodejs for my backed .

Thank You  
Kiran

---

<div class="post-metadata">

**Author:** ![Bujji1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bujji1/32/112962_2.png) [@Bujji1](https://discuss.elastic.co/u/Bujji1)\
**Post date:** [January 23, 2019, 5:04pm UTC](https://discuss.elastic.co/t/design-approach-for-counting-friends-unique-category-counts/164667/2 "2019-01-23T17:04:01Z")

</div>

Sorry to bug you guys again . Do I have to read all the friends Id's into my server side code and update each one by one ..? Any best approach you guys can suggest me ?

Thanks for your help  
Regards

---

<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:** [February 20, 2019, 5:04pm UTC](https://discuss.elastic.co/t/design-approach-for-counting-friends-unique-category-counts/164667/3 "2019-02-20T17:04:16Z")

</div>

Closed on February 20, 2019, 5:04pm UTC

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