# Get all the users being a manager

**URL:** <https://discuss.elastic.co/t/get-all-the-users-being-a-manager/160924>\
**Category:** Elasticsearch\
**Created:** [December 14, 2018, 3:05pm UTC](https://discuss.elastic.co/t/get-all-the-users-being-a-manager/160924 "2018-12-14T15:05:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MT\_WSM](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@MT\_WSM](https://discuss.elastic.co/u/MT_WSM)\
**Post date:** [December 14, 2018, 3:05pm UTC](https://discuss.elastic.co/t/get-all-the-users-being-a-manager/160924/1 "2018-12-14T15:05:49Z")

</div>

Hey guys,

I have a small issue today. I have a database containing thousands of users and some are the manager of others. To link them, I referenced the manager's id into its subordinates' column named 'ManagerId'.

Since some of my SQL queries were quite slow, I reproduced a few months ago my User table into an index (ElasticSearch) and today, for a new feature of my solution, I would like to only retrieve the managers.

At the beginning, I simply added a 'IsManager' field into the User index (ElasticSearch) and filled it by checking if the column 'ManagerId' of the table User (SQL) is containing the user being currently indexed's id (through a LINQ query - 'Any').

As expected my program is taking way more time to index all the users compared to before and I am wondering if the solution I implemented was the good one... Here is a summary of everything I said:

- SQL: User table containing a ManagerId column
- ElasticSearch: User index containing most of the User table's properties (ManagerId is included !)
- I would like to only retrieve the managers by querying ElasticSearch

I am posting here to know if there is another solution to get the wanted data without the IsManager and hopefully to win back the indexation time that I just lost.

Hoping I was clear enough into my explanations and wishing you a great weekend !  
Best 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:** [January 11, 2019, 3:05pm UTC](https://discuss.elastic.co/t/get-all-the-users-being-a-manager/160924/2 "2019-01-11T15:05:52Z")

</div>

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