DeprecationWarning: The 'http_auth' parameter is deprecated. Use 'basic_auth' or 'bearer_auth' parameters instead es = Elasticsearch(hosts=es_host_list1,http_auth=(es_user,es_pwd),timeout=15000)
时间: 2024-02-25 08:52:27 浏览: 53
这个警告说明在新版的 Elasticsearch 客户端库中,`http_auth` 参数已经被弃用,建议使用 `basic_auth` 或 `bearer_auth` 参数替代。可以将代码修改如下:
```python
from elasticsearch import Elasticsearch
es = Elasticsearch(
hosts=['https://localhost:9200'],
basic_auth=(es_user, es_pwd),
timeout=15000
)
```
这里使用了 `basic_auth` 参数来指定用户名和密码。如果需要使用 OAuth2 认证,可以使用 `bearer_auth` 参数。同时,`hosts` 参数也需要使用列表形式传递。
相关问题
DeprecationWarning: The 'body' parameter is deprecated and will be removed in a future version. Instead use individual parameters. res = es.search(index=es_index, body=data)
这个警告说明在新版的 Elasticsearch 客户端库中,`body` 参数已经被弃用,建议使用单独的参数来代替。可以将代码修改如下:
```python
from elasticsearch import Elasticsearch
es = Elasticsearch(
hosts=['https://localhost:9200'],
basic_auth=(es_user, es_pwd),
timeout=15000
)
res = es.search(
index=es_index,
body={'query': query},
size=size,
from_=start
)
```
这里使用了单独的参数来代替 `body` 参数。例如,`query` 参数用于指定查询语句。同时,对于分页查询,也可以使用 `size` 和 `from_` 参数来指定返回结果的数量和起始位置。
deprecationwarning: find_element_by_xpath is deprecated. please use find_element(by=by.xpath, value=xpath) instead
这是一个Python的DeprecationWarning警告,意思是find_element_by_xpath方法即将废弃。建议使用find_element(by=by.xpath, value=xpath)方法来代替。