1
我在使用elasticsearch dsl刪除項目時遇到問題。當我試圖過濾我的數據很容易,而且這樣的工作很好。Elasticsearch dsl刪除錯誤
def searchId(fileId):
s = Search().filter('term', fileId=fileId)
# for hit in s:
# print(str(hit.foreignKey))
response=s.execute()
# print(response.hits.total)
return response
掃描工作也:
def scanning():
s = Search()
i = 0
for hit in s.scan():
if hit.domain == 'Messages':
i+=1
print(str(hit.fileId) + " : " + str(hit.domain) + " : " + str(i))
但是,當我想刪除這樣的項目:
def deleteId(fileId):
s = Search().query('match', fileId=fileId)
response = s.delete()
return "Done"
我得到了一個錯誤:
Traceback (most recent call last): File "", line 1, in File "/home/o.solop/DataSearchEngine/datasearch/elasticapp/search.py", line 96, in deleteId response = s.delete() File "/usr/local/lib/python2.7/dist-packages/elasticsearch_dsl/search.py", line 660, in delete **self._params File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", line 73, in _wrapped return func(*args, params=params, **kwargs) File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/__init__.py", line 887, in delete_by_query raise ValueError("Empty value passed for a required argument.") ValueError: Empty value passed for a required argument.