Comments (1)
Hello, issues need more detail and should be in English, so I hope you don't mind if I close it.
However, I'm assuming your issue is that you're trying to create an index that already exists. Let's reproduce the issue by creating an index twice:
>>> from elasticsearch import Elasticsearch
>>> es = Elasticsearch("http://localhost:9200")
>>> es.indices.create(index="test")
ObjectApiResponse({'acknowledged': True, 'shards_acknowledged': True, 'index': 'test'})
>>> es.indices.create(index="test")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/q/src/elasticsearch-py/elasticsearch/_sync/client/utils.py", line 446, in wrapped
return api(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/home/q/src/elasticsearch-py/elasticsearch/_sync/client/indices.py", line 553, in create
return self.perform_request( # type: ignore[return-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/q/src/elasticsearch-py/elasticsearch/_sync/client/_base.py", line 423, in perform_request
return self._client.perform_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/q/src/elasticsearch-py/elasticsearch/_sync/client/_base.py", line 271, in perform_request
response = self._perform_request(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/q/src/elasticsearch-py/elasticsearch/_sync/client/_base.py", line 352, in _perform_request
raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(
elasticsearch.BadRequestError: BadRequestError(400, 'resource_already_exists_exception', 'index [test/9NZJh64dSWSsfaR7gF_EWQ] already exists')
As documented in https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/config.html#_ignoring_status_codes, status codes can be ignored using .options()
:
>>> es.options(ignore_status=400).indices.create(index="test")
ObjectApiResponse({'error': {'root_cause': [{'type': 'resource_already_exists_exception', 'reason': 'index [test/9NZJh64dSWSsfaR7gF_EWQ] already exists', 'index_uuid': '9NZJh64dSWSsfaR7gF_EWQ', 'index': 'test'}], 'type': 'resource_already_exists_exception', 'reason': 'index [test/9NZJh64dSWSsfaR7gF_EWQ] already exists', 'index_uuid': '9NZJh64dSWSsfaR7gF_EWQ', 'index': 'test'}, 'status': 400})
You can still see the error in the response, but the Elasticsearch client no longer raises an exception.
from elasticsearch-py.
Related Issues (20)
- Memory leak when using AsyncElasticsearch HOT 3
- search with nested sort results in 0 results HOT 8
- Helpers for `bulk` method such as `async_bulk` sleep in blocking manner, preventing graceful shutdown HOT 2
- `retry_on_status` setting does not work as expected with requests that should not be retried immediately
- Ability to pass headers to index function / other functions or Load headers from client HOT 1
- [BUG] Missing type and settings parameters in _sync/snapshots & _async/snapshots create_respository methods HOT 3
- Incremented connection delay are not of the stated duration HOT 3
- client fails to connect to self-managed Elasticsearch instance at https://localhost:9200 using all methods described in documentation HOT 2
- Bulk action typing does not allow `TypedDict`
- Unexpected ilm.put_lifecycle behavior
- Unable to connect via AsyncElasticsearch using ssl fingerprint HOT 1
- [DOC] Add more Python Client code examples to main Elasticsearch Docs | Set up and Upgrade Elasticsearch HOT 2
- [Documentation] Access to specialized clients is not documented HOT 1
- Test failures against NumPy 2.0.0rc1
- 8.13.1: pytest fails with `ImportError: cannot import name 'OrjsonSerializer' from 'elasticsearch.serializer` in elasticsearch/serializer.py HOT 8
- Add update_trained_model_deployment to ML client HOT 1
- Improve typing of string enums
- Setting custom node_pool_class does not work and seems to be a typo HOT 2
- py>=3.10 client>7.10.0 can not run HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-py.