我需要知道如何处理表单中的可选字段。这是我对该函数的完整代码...................................... ………………………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………………… ………………
def post(self):
print(request.headers['Content-Type'])
email = request.form.get('email')
title = request.form.get('title')
os_type=request.form.get('os_type')
device_type=request.form.get('device_type')
message=request.form.get('message')
file = request.files.get('file')
target_url = request.form.get('target_url')
print(email)
if email == None and email == '':
st="email is required"
data=error_call(st)
return(data),400,{'Content-Type': 'application/json'}
else:
return (email)
if title== None and title == '':
st="title is required"
data=error_call(st)
return(data),400,{'Content-Type': 'application/json'}
else:
if message==None and message== "":
return(error_call("message is requied")),400,{'Content-Type': 'application/json'}
else:
date=datetime.now()
if file:
a=20
print(a)
if a>20000:
return(error_call("sixe of file exceeded"))
else:
if file.filename == '': …Run Code Online (Sandbox Code Playgroud) 如何使用 python 中的bulkupdate 更新弹性搜索中的字段。我尝试了很多方法,但都出错了。在某些情况下,我收到文档丢失错误,如何同时更新和更新插入。而且附加到字段也不起作用。elasticsearch==7.9.1 是我在 python 中使用的包
for i in range(0, length, steps):
end_index = length-1 if i+steps>length else i+steps
temp_list = test_data[i: end_index]
bulk_file = ''
actions = [{
"_index": "test-data",
"_opt_type":"update",
"_type": "test-test-data",
"_id": test_row ['testId'],
"doc":{"script": {
"source": "ctx._source.DataIds.add(params.DataIds)",
"lang": "painless",
"params": {
"DataIds":test_row ['DataIds']
}
}}
}
for test_row in temp_list
]
helpers.bulk(es, actions)
Run Code Online (Sandbox Code Playgroud)
我得到的错误是这样的
{'update': {'_index': 'test-data', '_type': 'products', '_id': '333', 'status': 400, 'error': {'type': 'illegal_argument_exception', 'reason': 'failed
to execute script', 'caused_by': {'type': 'script_exception', 'reason': …Run Code Online (Sandbox Code Playgroud)