# How to manage fine grain permissions in Elasticsearch?

**URL:** https://discuss.elastic.co/t/how-to-manage-fine-grain-permissions-in-elasticsearch/19750
**Category:** Elasticsearch
**Created:** [September 12, 2014, 7:00am UTC](https://discuss.elastic.co/t/how-to-manage-fine-grain-permissions-in-elasticsearch/19750 "2014-09-12T07:00:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Manuel\_Vacelet\_2](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Manuel\_Vacelet\_2](https://discuss.elastic.co/u/Manuel_Vacelet_2)
#### Post date: [September 12, 2014, 7:00am UTC](https://discuss.elastic.co/t/how-to-manage-fine-grain-permissions-in-elasticsearch/19750/1 "2014-09-12T07:00:07Z")

</div>

Hello,

I need to store in a consistent way the role/groups that can access the  
information but I'm not sure what's the best way to do it.

Summary: I have 2 kinds of docs "tweet" and "blog":

- At tweet level, I store the group name allowed to access the  
information
- blog is more complex, there are metadata (title, description, nature,  
...) but some of those informations can be restricted to some groups of  
user (only admin, or logged\_in users)

What the best way to map this with Elasticsearch ?

As of today, I end up with documents like:

/tweet/455  
{  
id: 112,  
ugroups: ["restricted\_user", "admin"],  
description: "foo",  
},  
{  
id: 113,  
ugroups: ["anonymous"]  
description: "foo",  
}

and

/blog/500  
{  
id: 5,  
fields: [  
{  
"nature": {  
"value": "foo",  
"ugroup": ["admin"]  
}  
}  
]  
}  
{  
id: 6,  
fields: [  
{  
"comment": {  
"value": "foo",  
"ugroup": ["anonymous"]  
}  
}  
]  
}

When user want to search in tweet, that's easy, I build a term query with  
words submitted by the user and I append the groups the user belongs to  
this query.

But how to make a query that will take this "ugroup" thing at various level  
?

Ideally I could issue a query like:

- search in tweet with tweet.ugroup: "anonymous" and in blog with  
blog.fields.\*.ugroup:  
"anonymous"

## Is there a way to write such a query ?

Manuel VACELET

> **[Enalean - Make your software a competitive advantage](https://www.enalean.com/)**
>
> Provider of Tuleap Enterprise, the first 100% Libre & Open Source Development, Collaboration and Workflow Platform. Build faster quality software!

  
@vaceletm

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAP66XbEYW786uoZ2p6So0G2p31NX1owejaq0X1QDuZd8Nq7a1A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAP66XbEYW786uoZ2p6So0G2p31NX1owejaq0X1QDuZd8Nq7a1A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:02am UTC](https://discuss.elastic.co/t/how-to-manage-fine-grain-permissions-in-elasticsearch/19750/2 "2017-07-06T01:02:52Z")

</div>


