0

enter code herewhen i try using below code got errors Like:

if es_client.indices.exists_alias(index_alias):
        print("#########################################")
        current_index = list(es_client.indices.get(index_alias).keys())[0]
        print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@: ", current_index)
        print('LOG :: => Index associated with alias is', list(
            es_client.indices.get(index_alias).keys())[0])

Error:

File "sample.py", line 719, in main
    if es_client.indices.exists_alias(index_alias):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elasticsearch/_sync/client/utils.py", line 307, in wrapped
    raise TypeError(
TypeError: Positional arguments can't be used with Elasticsearch API methods. Instead only use keyword arguments.



Later added keyword argument (name = index name or index = index name)  and got different error

if es_client.indices.exists_alias(name = index_alias):

File "sample.py", line 719, in main
    if es_client.indices.exists_alias(name=index_alias):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elasticsearch/_sync/client/utils.py", line 414, in wrapped
    return api(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elasticsearch/_sync/client/indices.py", line 1261, in exists_alias
    return self.perform_request(  # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elasticsearch/_sync/client/_base.py", line 389, in perform_request
    return self._client.perform_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elasticsearch/_sync/client/_base.py", line 320, in perform_request
    raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(
elasticsearch.AuthenticationException: AuthenticationException(401, 'None')
toyota Supra
  • 3,181
  • 4
  • 15
  • 19
Madhu
  • 13
  • 5
  • Is there any solution for this problem .I have tried by keeping the name/index = alias_index parameter but issue is not resolved . – Madhu Jul 25 '23 at 08:34

0 Answers0