From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 25 Jan 2023 16:37:26 +0000 (-0800) Subject: Fix broken date range search X-Git-Tag: v1.12.1~1^2~2^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2509%2Fhead;p=thirdparty%2Fpaperless-ngx.git Fix broken date range search --- diff --git a/src/documents/views.py b/src/documents/views.py index 87862fe072..e2807edff0 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -468,14 +468,16 @@ class DocumentViewSet( class SearchResultSerializer(DocumentSerializer): def to_representation(self, instance): doc = Document.objects.get(id=instance["id"]) - commentTerm = instance.results.q.subqueries[0] - comments = ",".join( - [ - str(c.comment) - for c in Comment.objects.filter(document=instance["id"]) - if commentTerm.text in c.comment - ], - ) + comments = "" + if hasattr(instance.results.q, "subqueries"): + commentTerm = instance.results.q.subqueries[0] + comments = ",".join( + [ + str(c.comment) + for c in Comment.objects.filter(document=instance["id"]) + if commentTerm.text in c.comment + ], + ) r = super().to_representation(doc) r["__search_hit__"] = { "score": instance.score,