]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix broken date range search 2509/head
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Wed, 25 Jan 2023 16:37:26 +0000 (08:37 -0800)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Wed, 25 Jan 2023 16:37:26 +0000 (08:37 -0800)
src/documents/views.py

index 87862fe072332a1e0ed4e3cb0d0c7803cee98c03..e2807edff02f24bc3f32778e75d71df6bac47922 100644 (file)
@@ -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,