我对此有困难:以下所有的回报405,我不知道为什么:
data = {
"xxx" : "status",
"value" : "incomplete"
}
headers = {'Content-type': 'application/json'}
response = requests.post(f'http://localhost:9200/my_index', data=json.dumps(data))
response = requests.post(f'http://localhost:9200/my_index', data=json.dumps(data), headers=headers)
response = requests.post(f'http://localhost:9200/my_index', json=data)
response = requests.post(f'http://localhost:9200/my_index', json=data, headers=headers) 注:我也尝试过用"_“代替:他们都得到406。
ES确实在运行,我可以在CLI上使用Postman和curl。
使用上述尝试(结尾为“./_doc/1”)的requests.put获得406或401,但上述情况之一除外:
response = requests.put(f'http://localhost:9200/my_index/_doc/2', data=json.dumps(data), headers=headers)..。它可以工作(201或200取决于索引是否已经存在)。
操作系统是Linux 20,ES是7.16.3。
发布于 2022-01-30 19:11:01
根据文档,必须将_doc放在索引名称之后:
PUT /<target>/_doc/<_id>
POST /<target>/_doc/您可以选择“弹性”是否会为您创建id,也可以指定一个id。
https://stackoverflow.com/questions/70913687
复制相似问题