-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with Highlight - KeyError: 0 #126
Comments
Hey, thanks for the report. |
Hey below are my configurations drf-haystack==1.8.1 |
For anyone else facing the same problem. I override the
|
Thanks! I'll see if I can squeeze in some time to make a fix out of this! |
I get the error below when I add HaystackHighlightFilter to a faceted viewset and use face url like
http://127.0.0.1:8002/api/v1/search/facets/?first_name=judith¶ms=u_type_exact%3AStudent
When I check the to_representation(self, instance) and print(instance.highlighted) here is the structure of the instance.highlighted
{'text': ['<em>Judith</em>\nAmaefula\nSaint Hopkins\nMechanical Engineering\nMedicine']}
Is there an update that addresses this issues?
File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner response = get_response(request) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response response = self.process_exception_by_middleware(e, request) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/viewsets.py", line 95, in view return self.dispatch(request, *args, **kwargs) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/views.py", line 494, in dispatch response = self.handle_exception(exc) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/views.py", line 454, in handle_exception self.raise_uncaught_exception(exc) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/views.py", line 491, in dispatch response = handler(request, *args, **kwargs) File "/Users/ebuka/dev/university/core/api.py", line 46, in facets return Response(serializer.data) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/serializers.py", line 537, in data ret = super(Serializer, self).data File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/serializers.py", line 262, in data self._data = self.to_representation(self.instance) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/serializers.py", line 504, in to_representation ret[field.field_name] = field.to_representation(attribute) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/fields.py", line 1816, in to_representation return method(value) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/drf_haystack/serializers.py", line 411, in get_objects return serializer.data File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/serializers.py", line 742, in data ret = super(ListSerializer, self).data File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/serializers.py", line 262, in data self._data = self.to_representation(self.instance) File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/serializers.py", line 660, in to_representation self.child.to_representation(item) for item in iterable File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/rest_framework/serializers.py", line 660, in <listcomp> self.child.to_representation(item) for item in iterable File "/Users/ebuka/.virtualenvs/university/lib/python3.6/site-packages/drf_haystack/serializers.py", line 242, in to_representation ret["highlighted"] = instance.highlighted[0] KeyError: 0
The text was updated successfully, but these errors were encountered: