# How to exclude many documents

**URL:** <https://discuss.elastic.co/t/how-to-exclude-many-documents/148899>\
**Category:** Elasticsearch\
**Created:** [September 17, 2018, 11:46pm UTC](https://discuss.elastic.co/t/how-to-exclude-many-documents/148899 "2018-09-17T23:46:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nenad](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@Nenad](https://discuss.elastic.co/u/Nenad)\
**Post date:** [September 17, 2018, 11:46pm UTC](https://discuss.elastic.co/t/how-to-exclude-many-documents/148899/1 "2018-09-17T23:46:44Z")

</div>

I have indexed all Users (10 million records) and I plan to index a Table that store visits of a user to another user.  
I wish to show to the User 100 users they have never visited.  
For some users I have to exclude up to 80'000 already visited users.

How should I Index the visits? As 1 doc for one visit or all visits from a user in 1 doc?  
And how should I query the proposed users?

I have seen there is now the join datatype but I'm not sure uf this is the right way and how to use it.

I'm using ES 6.4.

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [September 18, 2018, 4:43am UTC](https://discuss.elastic.co/t/how-to-exclude-many-documents/148899/2 "2018-09-18T04:43:16Z")

</div>

Hi,

What about this: [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html#query-dsl-terms-lookup](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html#query-dsl-terms-lookup)

May need to check about the size of your field where you store your ids.

Hope it can help.

---

<div class="post-metadata">

**Author:** ![Nenad](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@Nenad](https://discuss.elastic.co/u/Nenad)\
**Post date:** [September 18, 2018, 6:12am UTC](https://discuss.elastic.co/t/how-to-exclude-many-documents/148899/3 "2018-09-18T06:12:33Z")

</div>

Hi,  
This seems to require that I store all visits of one user inside one doc, but one field supports up to around 10'000 chars and will not allow me to store more then 1300 7-digit numbers.

---

<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, 2018, 6:12am UTC](https://discuss.elastic.co/t/how-to-exclude-many-documents/148899/4 "2018-10-16T06:12:34Z")

</div>

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