You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to clear indexes that do not use the default haystack ID.
Actual behaviour
Fails with the following error:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/etc/cravus/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/etc/cravus/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/etc/cravus/env/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/etc/cravus/env/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/etc/cravus/env/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 183, in handle
return super(Command, self).handle(*items, **options)
File "/etc/cravus/env/lib/python3.4/site-packages/django/core/management/base.py", line 548, in handle
label_output = self.handle_label(label, **options)
File "/etc/cravus/env/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 188, in handle_label
self.update_backend(label, using)
File "/etc/cravus/env/lib/python3.4/site-packages/haystack/management/commands/update_index.py", line 289, in update_backend
backend.remove(rec_id, commit=self.commit)
File "/etc/cravus/env/lib/python3.4/site-packages/haystack/backends/elasticsearch_backend.py", line 196, in remove
doc_id = get_identifier(obj_or_string)
File "/etc/cravus/env/lib/python3.4/site-packages/haystack/utils/__init__.py", line 37, in default_get_identifier
return u"%s.%s" % (get_model_ct(obj_or_string), obj_or_string._get_pk_val())
File "/etc/cravus/env/lib/python3.4/site-packages/haystack/utils/__init__.py", line 80, in get_model_ct
return "%s.%s" % get_model_ct_tuple(model)
File "/etc/cravus/env/lib/python3.4/site-packages/haystack/utils/__init__.py", line 74, in get_model_ct_tuple
return (model._meta.app_label, model._meta.model_name)
AttributeError: 'int' object has no attribute '_meta'
Steps to reproduce the behaviour
Add HAYSTACK_ID_FIELD='haystack_id' # or some other name in the settings file
Create object and index, with the id field being used
Remove object
Run python manage.py update_index --remove
Configuration
Haystack version: 2.8.1
On account of the fact that haystack provisions the settings option HAYSTACK_ID_FIELD, this should be taken into account when attempting to remove items from the index. However, this is not presently being done, as seen here:
index_pks = index_pks.values_list('pk', 'id')
The fix would be:
from haystack.constants import ID
...
index_pks = index_pks.values_list('pk', ID)
This issue is an extension of a previous addressed issue #1323
The text was updated successfully, but these errors were encountered:
butteredtoast
changed the title
update_index --remove disregards HAYSTACK_ID_FIELD
update_index --remove disregards HAYSTACK_ID_FIELD
Mar 16, 2019
Expected behaviour
It should be possible to clear indexes that do not use the default haystack ID.
Actual behaviour
Fails with the following error:
Steps to reproduce the behaviour
HAYSTACK_ID_FIELD='haystack_id' # or some other name
in the settings fileid
field being usedpython manage.py update_index --remove
Configuration
On account of the fact that haystack provisions the settings option
HAYSTACK_ID_FIELD
, this should be taken into account when attempting to remove items from the index. However, this is not presently being done, as seen here:The fix would be:
This issue is an extension of a previous addressed issue #1323
The text was updated successfully, but these errors were encountered: