Trying to run queries with Elasticsearch but getting errors, help would be appreciated!
elasticsearch.exceptions.AuthorizationException: AuthorizationException(403, 'security_exception', 'action [indices:data/write/index] is unauthorized for API key id [aURW5X8BEbj8_1N8flEI] of user [elastic-userconsole-proxy], this action is granted by the index privileges [create_doc,create,index,write,all]')
Tried using basic_auth for connecting but it wasnt working, http_auth has been deprecated so the only solution left was to use api keys. Connecting is succesfull but queries are not running
Connection code below
from elasticsearch import Elasticsearch
from configparser import ConfigParser
config = ConfigParser()
config.read('connection.ini')
es = Elasticsearch(
cloud_id=config['ELASTIC']['CLOUD_ID'],
api_key=(config['ELASTIC']['API_ID'], config['ELASTIC']['API_KEY'])
)
def check_connection():
if es.ping:
return print(True)
else:
return print(False)
# check_connection()
print(es.info())
Query code below
def insert_query(reserved: str, name: str, address: str, group: str, email: str, rarity: int):
es.index(
index=reserved,
document={
'name': name,
'address': address,
'group': group,
'email': email,
'rarity': rarity
}
)