A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
comment search highlighting
Michael Shamoonb869ad02a1f1
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.htmlindex 80aedb7f2..0eb965a22 100644--- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html+++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html@@ -25,7 +25,13 @@</h5></div><p class="card-text">- <span *ngIf="document.__search_hit__" [innerHtml]="document.__search_hit__.highlights"></span>+ <span *ngIf="document.__search_hit__ && document.__search_hit__.highlights" [innerHtml]="document.__search_hit__.highlights"></span>+ <span *ngIf="document.__search_hit__ && document.__search_hit__.comment_highlights">+ <svg width="1em" height="1em" fill="currentColor" class="me-2">+ <use xlink:href="assets/bootstrap-icons.svg#chat-left-text"/>+ </svg>+ <span [innerHtml]="document.__search_hit__.comment_highlights"></span>+ </span><span *ngIf="!document.__search_hit__" class="result-content">{{contentTrimmed}}</span></p>diff --git a/src-ui/src/app/data/paperless-document.ts b/src-ui/src/app/data/paperless-document.tsindex 8b038d79e..cdee624af 100644--- a/src-ui/src/app/data/paperless-document.ts+++ b/src-ui/src/app/data/paperless-document.ts@@ -10,6 +10,7 @@ export interface SearchHit {rank?: numberhighlights?: string+ comment_highlights?: string}export interface PaperlessDocument extends ObjectWithId {diff --git a/src/documents/views.py b/src/documents/views.pyindex e313ae17e..c65b6f0b4 100644--- a/src/documents/views.py+++ b/src/documents/views.py@@ -458,10 +458,19 @@ 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+ ],+ )r = super().to_representation(doc)r["__search_hit__"] = {"score": instance.score,- "highlights": instance.highlights("content", text=doc.content)+ "highlights": instance.highlights("content", text=doc.content),+ "comment_highlights": instance.highlights("content", text=comments)if docelse None,"rank": instance.rank,