![](/img/trans.png)
[英]How to delete documents from multiple indices using particular field name in elasticsearch python?
[英]How can I send multiple documents to Elasticsearch datastream using Python?
我正在嘗試將 Python 中的大量文檔索引到 Elasticsearch,閱讀文檔后,他們參考了這個例子。
當我對普通索引進行索引時,此示例效果很好,但是,當我嘗試對可以接受動態內容的數據流,甚至是全新的數據流進行索引時,我收到此錯誤:
Traceback (most recent call last):
File "/Users/Downloads/elasticsearch-py-main/examples/bulk-ingest/bulk-ingest.py", line 111, in <module>
main()
File "/Users/Downloads/elasticsearch-py-main/examples/bulk-ingest/bulk-ingest.py", line 102, in main
for ok, action in bulk(
File "/opt/homebrew/lib/python3.9/site-packages/elasticsearch/helpers/actions.py", line 524, in bulk
for ok, item in streaming_bulk(
File "/opt/homebrew/lib/python3.9/site-packages/elasticsearch/helpers/actions.py", line 438, in streaming_bulk
for data, (ok, info) in zip(
File "/opt/homebrew/lib/python3.9/site-packages/elasticsearch/helpers/actions.py", line 355, in _process_bulk_chunk
yield from gen
File "/opt/homebrew/lib/python3.9/site-packages/elasticsearch/helpers/actions.py", line 274, in _process_bulk_chunk_success
raise BulkIndexError(f"{len(errors)} document(s) failed to index.", errors)
elasticsearch.helpers.BulkIndexError: 2 document(s) failed to index.
我找不到這方面的任何信息,如何使用 Elasticsearch Python 連接器批量索引我的數據?
這可能是因為在將文檔發送到數據 stream 時,您需要將操作設置為create
而不是index
{ "create": {"_id": "123"}}
{ "field": "value" }
使用Python 批量助手,您需要在批量操作中顯式設置'_op_type': 'create'
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.