mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 00:05:21 +01:00
Feature: global search, keyboard shortcuts / hotkey support (#6449)
This commit is contained in:
parent
40289cd714
commit
c6e7d06bb7
51 changed files with 2970 additions and 683 deletions
|
|
@ -796,6 +796,34 @@ class DocumentSerializer(
|
|||
)
|
||||
|
||||
|
||||
class SearchResultSerializer(DocumentSerializer):
|
||||
def to_representation(self, instance):
|
||||
doc = (
|
||||
Document.objects.select_related(
|
||||
"correspondent",
|
||||
"storage_path",
|
||||
"document_type",
|
||||
"owner",
|
||||
)
|
||||
.prefetch_related("tags", "custom_fields", "notes")
|
||||
.get(id=instance["id"])
|
||||
)
|
||||
notes = ",".join(
|
||||
[str(c.note) for c in doc.notes.all()],
|
||||
)
|
||||
r = super().to_representation(doc)
|
||||
r["__search_hit__"] = {
|
||||
"score": instance.score,
|
||||
"highlights": instance.highlights("content", text=doc.content),
|
||||
"note_highlights": (
|
||||
instance.highlights("notes", text=notes) if doc else None
|
||||
),
|
||||
"rank": instance.rank,
|
||||
}
|
||||
|
||||
return r
|
||||
|
||||
|
||||
class SavedViewFilterRuleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = SavedViewFilterRule
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue