elasticsearch_dsl 添加数据
时间: 2023-08-21 12:04:55 浏览: 106
要使用elasticsearch_dsl添加数据,首先需要建立与ElasticSearch的连接。可以使用以下代码创建连接:
```python
from elasticsearch_dsl import connections
connections.create_connection(hosts=['127.0.0.1:9200'], timeout=20)
```
接下来,您需要获取要添加数据的index和table信息。您可以使用以下代码获取index和table的名称:
```python
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
client = Elasticsearch('127.0.0.1:9200')
indexs = client.indices.get('*')
indexnames = indexs.keys()
index = indexnames<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [通过Python库elasticsearch_dsl处理elasticsearch](https://blog.csdn.net/xzwspy/article/details/82665381)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [零基础python爬虫48小时速成](https://download.csdn.net/download/weixin_36643308/88220343)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文