pythonelasticsearchelastic-stack

Elasticsearch client: Unable to get data when * included in index name


I have written the following code in python to get data from my Elastic deployment:

from elasticsearch import Elasticsearch
client = Elasticsearch(<endpoint>,api_key=(<API key ID>,<secret>))
client.get(index="abc-001",id = '--index001')

This code works correctly and gives me objectAPIresponse.

But making small change to the code as such:

client.get(index="abc-*",id = '--index001')

gives me an error:

AuthorizationException: AuthorizationException(403, 'security_exception', 'action [indices:data/read/get] is unauthorized for API key id [<id>] of user [<user>], this action is granted by the index privileges [read,all]')

I face same issue when using client.exists(index,id)

I need to assume that I don't know the full index name and need to know if index "abc-*" does exists in deployment. Even somehow if we can ignore the id and just know if the index is existing, that would be helpful.


Solution

  • Problem

    as the error said, you don't have required permissions to access the indexName*. Probably your previlages has been limited to single index names (e.g abc-001, abc-002, etc) and not to the abc-*

    So please check your role previlages to see wheter you have such an access or not. there are two ways to do so:

    1. using Kibana management dashboard, the roles section
    2. using below query:
    GET _security/role/<your-role-name>
    

    if you were not granted, ask for it, since there is no other way to solve the problem!

    Solution

    You need to get such an access, to do so you can use both the Kibana dashboard (simpler way) or the querying approach. (here you can find how to do so)