我使用Django Web框架集成了Elasticsearch和haystack。现在我要删除不存在的
使用 call_command('update_index --remove')函数从Elasticsearch索引中获取数据。
我的问题是当我运行 update_index --remove 时,出现以下错误:
Indexing 6 notes
[ERROR/MainProcess] Error updating core using default
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/haystack/management/commands/update_index.py",
line 230, in handle
self.update_backend(label, using)
File "/usr/local/lib/python3.6/dist-packages/haystack/management/commands/update_index.py",
line 308, in update_backend
index_total = SearchQuerySet(using=backend.connection_alias).models(model).count()
File "/usr/local/lib/python3.6/dist-packages/haystack/query.py", line 522, in count
return len(self)
File "/usr/local/lib/python3.6/dist-packages/haystack/query.py", line 86, in __len__
self._result_count = self.query.get_count()
File "/usr/local/lib/python3.6/dist-packages/haystack/backends/__init__.py", line 619, in
get_count
self.run()
File "/usr/local/lib/python3.6/dist-packages/haystack/backends/elasticsearch_backend.py",
line 951, in run
results = self.backend.search(final_query, **search_kwargs)
File "/usr/local/lib/python3.6/dist-packages/haystack/backends/__init__.py", line 33, in
wrapper
return func(obj, query_string, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/haystack/backends/elasticsearch_backend.py",
line 524, in search
_source=True)
File "/usr/local/lib/python3.6/dist-packages/elasticsearch/client/utils.py", line 84, in
_wrapped
return func(*args, params=params, **kwargs)
TypeError: search() got an unexpected keyword argument 'doc_type'
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381,
in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 375,
in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 316, in
run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 353, in
execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/dist-packages/haystack/management/commands/update_index.py",
line 230, in handle
self.update_backend(label, using)
File "/usr/local/lib/python3.6/dist-packages/haystack/management/commands/update_index.py",
line 308, in update_backend
index_total = SearchQuerySet(using=backend.connection_alias).models(model).count()
File "/usr/local/lib/python3.6/dist-packages/haystack/query.py", line 522, in count
return len(self)
File "/usr/local/lib/python3.6/dist-packages/haystack/query.py", line 86, in __len__
self._result_count = self.query.get_count()
File "/usr/local/lib/python3.6/dist-packages/haystack/backends/__init__.py", line 619, in
get_count
self.run()
File "/usr/local/lib/python3.6/dist-packages/haystack/backends/elasticsearch_backend.py",
line 951, in run
results = self.backend.search(final_query, **search_kwargs)
File "/usr/local/lib/python3.6/dist-packages/haystack/backends/__init__.py", line 33, in
wrapper
return func(obj, query_string, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/haystack/backends/elasticsearch_backend.py",
line 524, in search
_source=True)
File "/usr/local/lib/python3.6/dist-packages/elasticsearch/client/utils.py", line 84, in
_wrapped
return func(*args, params=params, **kwargs)
TypeError: search() got an unexpected keyword argument 'doc_type'
我正在使用:
django-haystack == 2.8.1
elasticsearch == 7.1.0
elasticsearch-7.4.0 => 服务器
注意:
不推荐
HAYSTACK_SIGNAL_PROCESSOR ='haystack.signals.RealtimeSignalProcessor'
此方法不适合我。我没有使用django进行数据插入。仅用于过滤和删除目的。
update_index --age = 24 的相同问题。
答案 0 :(得分:1)
我认为问题在于您正在使用Elasticsearch 7和Haystack only supports versions up to 5:
Haystack当前仅支持Elasticsearch 1.x和2.x。尚不支持Elasticsearch 5.x,如果您需要帮助,请参阅#1383。
我看到两个选择:
您看到的错误:
TypeError:search()得到了意外的关键字参数'doc_type'
与在Elasticsearch 7中已删除文档类型这一事实有关。
希望有帮助!