# Noob looking for some guidance on Document level secure index

**URL:** https://discuss.elastic.co/t/noob-looking-for-some-guidance-on-document-level-secure-index/37418
**Category:** Elasticsearch
**Created:** [December 16, 2015, 11:49pm UTC](https://discuss.elastic.co/t/noob-looking-for-some-guidance-on-document-level-secure-index/37418 "2015-12-16T23:49:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![adamgins](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@adamgins](https://discuss.elastic.co/u/adamgins)
#### Post date: [December 16, 2015, 11:49pm UTC](https://discuss.elastic.co/t/noob-looking-for-some-guidance-on-document-level-secure-index/37418/1 "2015-12-16T23:49:04Z")

</div>

Hi, I searched around (including API) to try and find some recent direction for supporting secure search based on document level access control. (I expact a ton of people have asked the same question... just could not find a recent doc/thread (maybe I just missed it)

Background:

I have a collection of document trees. Each document is accessible by a list of users.  
I would like users to be able to search the following ways:

1. within a document that they have access to - for example I want to find the word "Sydney" within the tree. Users who do not have access to this document should not be able to use this index or see search results.

2. site wide: across documents a user has access to. For example, I want to search across all my documents for a tag #surf and see all documents that have been tagged with "surf"

There could millions of users and millions of document trees. I expect each document tree could have thousands of nodes. ... For example you can comment on a document and there could be thousands of comments on a document.

What's the best way to implement this with Elasticsearch (I am planning on using Found to host it)?

My current thought was to have an index for each document and then somehow only allowing users with access to that document to use the index. I was not sure exactly how to prevent non-authorized users from using an index?

For the sitewide search, I am not sure how I'd aggregate all my document tree indices together, perhaps a user index ... but that would seem like a huge duplication of data.

Anyway, any guidance help appreciated.

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [December 17, 2015, 12:16am UTC](https://discuss.elastic.co/t/noob-looking-for-some-guidance-on-document-level-secure-index/37418/2 "2015-12-17T00:16:25Z")

</div>

Once solution is if you have control over the documents, you can use a  
filtered alias:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#filtered](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#filtered)

You create the index and documents are normal, but each document contains a  
property/field that will determines which user have access to it. Each user  
has access to an filtered alias, not the entire index.

The major downside is that it is difficult to add/remove users since each  
document would need to be updated.

---

<div class="post-metadata">

### Author: ![adamgins](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@adamgins](https://discuss.elastic.co/u/adamgins)
#### Post date: [December 17, 2015, 12:40am UTC](https://discuss.elastic.co/t/noob-looking-for-some-guidance-on-document-level-secure-index/37418/3 "2015-12-17T00:40:35Z")

</div>

Thanks. Looking at that now

So how would you restrict access to "test1"? ie I see how you can filter by "alias2" but a user could still hit the "test1" index and see all docs they shouldn't, right? Is there some other way I should be restricting access so users cannot use "test1"?

 ![](https://us1.discourse-cdn.com/elastic/original/2X/6/63e79d694b4ee905cdf29e424eba0752a298cc7d.png)

---

<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: [July 5, 2017, 11:30pm UTC](https://discuss.elastic.co/t/noob-looking-for-some-guidance-on-document-level-secure-index/37418/4 "2017-07-05T23:30:22Z")

</div>


