# Permissions

**URL:** <https://discuss.elastic.co/t/permissions/31857>\
**Category:** Elasticsearch\
**Created:** [October 8, 2015, 2:46pm UTC](https://discuss.elastic.co/t/permissions/31857 "2015-10-08T14:46:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kodermax](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@kodermax](https://discuss.elastic.co/u/kodermax)\
**Post date:** [October 8, 2015, 2:46pm UTC](https://discuss.elastic.co/t/permissions/31857/1 "2015-10-08T14:46:06Z")

</div>

i have two types

```
contacts: {
  'full_name': 'test',
  'first_name': 'john',
  'last_name': 'sendy'
  'perms': ['D123','U3423']
}

user_perms: [{
  'id': 123,
  'attr': ['D123']
},{
  'id': 3423,
  'attr': []
}]

```

my filter

```
$params = [
                'index' => 'portal',
                'type' => 'contact',
                'size' => 50,
                'body' => [
                    'query' => [
                        'filtered' => [
                            'query' => [
                                'match' => [
                                    'full_name' => [
                                        'query' => $value,
                                        'operator' => 'and',
                                        'fuzziness' => 1
                                    ]
                                ]
                            ],
                            'filter' => [
                                        'terms' =>
                                        [
                                            'perms.original' => [
                                                'index' => 'portal',
                                                'type' => 'user_perms',
                                                'id' => "3081",
                                                'path' => 'attr.original'
                                            ]
                                        ]
                            ]
                        ]
                    ]
                ]
            ];

```

I'd like to if user have empty attr then he see all contacts, if user have some attr then see only contacts with this attrs.  
Help please.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 8, 2015, 9:21pm UTC](https://discuss.elastic.co/t/permissions/31857/2 "2015-10-08T21:21:52Z")

</div>

Then you'd need something like Shield to do this, there is nothing inbuilt in ES to handle it.

---

<div class="post-metadata">

**Author:** ![kodermax](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@kodermax](https://discuss.elastic.co/u/kodermax)\
**Post date:** [October 9, 2015, 8:03am UTC](https://discuss.elastic.co/t/permissions/31857/3 "2015-10-09T08:03:45Z")

</div>

i.e. before filtering if the user has no attributes, then the filter does not specify, Yes?

---

<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:45pm UTC](https://discuss.elastic.co/t/permissions/31857/4 "2017-07-05T23:45:42Z")

</div>

Closed on July 5, 2017, 11:45pm UTC


