# 'search\_phase\_execution\_exception', 'action \[indices:data/read/search\[phase/query\]\] is unauthorized for user

**URL:** <https://discuss.elastic.co/t/search-phase-execution-exception-action-indices-data-read-search-phase-query-is-unauthorized-for-user/269657>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [April 9, 2021, 4:45am UTC](https://discuss.elastic.co/t/search-phase-execution-exception-action-indices-data-read-search-phase-query-is-unauthorized-for-user/269657 "2021-04-09T04:45:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sair\_ramos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sair_ramos/32/81309_2.png) [@sair\_ramos](https://discuss.elastic.co/u/sair_ramos)\
**Post date:** [April 9, 2021, 4:45am UTC](https://discuss.elastic.co/t/search-phase-execution-exception-action-indices-data-read-search-phase-query-is-unauthorized-for-user/269657/1 "2021-04-09T04:45:13Z")

</div>

i use a script in python to search, index and uptade data and everything works but sometimes give this error many times in a row \*\*'search\_phase\_execution\_exception', 'action [indices:data/read/search[phase/query]] is unauthorized for user \*\*

this is de role information

```auto
{
  "organizer" : {
    "cluster" : [
      "all"
    ],
    "indices" : [
      {
        "names" : [
          "data-report*"
        ],
        "privileges" : [
          "all"
        ],
        "allow_restricted_indices" : false
      }
    ],
    "applications" : [],
    "run_as" : [],
    "metadata" : { },
    "transient_metadata" : {
      "enabled" : true
    }
  }
}

```

`

---

<div class="post-metadata">

**Author:** ![spong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spong/32/54343_2.png) [@spong](https://discuss.elastic.co/u/spong)\
**Post date:** [April 12, 2021, 8:41pm UTC](https://discuss.elastic.co/t/search-phase-execution-exception-action-indices-data-read-search-phase-query-is-unauthorized-for-user/269657/2 "2021-04-12T20:41:59Z")

</div>

Hey there @sair_ramos, welcome to the community! 👋

Can you verify that your script is only performing actions against the specified `data-report*` Elasticsearch index pattern? If you happen to be using a more inclusive index pattern like `data-*` in your scripts/queries that could result in the error you're seeing as the user may not have access to the other indices.

Of course you could change `data-report*` -\> `*` within your role, thereby granting access to _all_ indices, but better to identify exactly what indices you're querying in your script and add the necessary privileges to those as well to ensure you're not modifying data you're not expecting to.

Hope this helps -- cheers!  
Garrett

---

<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:** [May 10, 2021, 8:42pm UTC](https://discuss.elastic.co/t/search-phase-execution-exception-action-indices-data-read-search-phase-query-is-unauthorized-for-user/269657/3 "2021-05-10T20:42:17Z")

</div>

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