Merge pull request #2509 from paperless-ngx/fix-2508

Fix: date range search broken in 1.12
This commit is contained in:
shamoon 2023-01-25 08:48:15 -08:00 committed by GitHub
commit 1871ef1a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -468,14 +468,16 @@ class DocumentViewSet(
class SearchResultSerializer(DocumentSerializer): class SearchResultSerializer(DocumentSerializer):
def to_representation(self, instance): def to_representation(self, instance):
doc = Document.objects.get(id=instance["id"]) doc = Document.objects.get(id=instance["id"])
commentTerm = instance.results.q.subqueries[0] comments = ""
comments = ",".join( if hasattr(instance.results.q, "subqueries"):
[ commentTerm = instance.results.q.subqueries[0]
str(c.comment) comments = ",".join(
for c in Comment.objects.filter(document=instance["id"]) [
if commentTerm.text in c.comment str(c.comment)
], for c in Comment.objects.filter(document=instance["id"])
) if commentTerm.text in c.comment
],
)
r = super().to_representation(doc) r = super().to_representation(doc)
r["__search_hit__"] = { r["__search_hit__"] = {
"score": instance.score, "score": instance.score,