From a5526eb7b9d9ef3dc59337061cf05d185720c2a8 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Garcia Date: Mon, 19 Aug 2024 15:29:35 +0200 Subject: [PATCH] enhance workflow search --- backoffice/backoffice/workflows/api/views.py | 9 +++++--- backoffice/backoffice/workflows/documents.py | 23 +++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/workflows/api/views.py index 3772df0d..3ab70eed 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/workflows/api/views.py @@ -257,14 +257,17 @@ def __init__(self, *args, **kwargs): OrderingFilterBackend, ] search_fields = { - "workflow_type", - "status", - "is_update", + "data.ids.value", + "data.ids.schema", + "data.name.value", + "data.name.preferred_name", + "data.email_addresses.value", } filter_fields = { "status": "status", "workflow_type": "workflow_type", + "is_update": "is_update" } ordering_fields = {"_updated_at": "_updated_at"} diff --git a/backoffice/backoffice/workflows/documents.py b/backoffice/backoffice/workflows/documents.py index edcad401..3db73dc8 100644 --- a/backoffice/backoffice/workflows/documents.py +++ b/backoffice/backoffice/workflows/documents.py @@ -9,7 +9,28 @@ class WorkflowDocument(Document): id = fields.TextField() workflow_type = fields.KeywordField() - data = fields.ObjectField() + data = fields.ObjectField( + properties={ + "ids": fields.ObjectField( + properties={ + "value": fields.KeywordField(), + "schema": fields.KeywordField(), + } + ), + "name": fields.ObjectField( + properties={ + "value": fields.TextField(), + "preferred_name": fields.TextField(), + } + ), + "email_address": fields.ObjectField( + properties={ + "value": fields.KeywordField(), + "current": fields.BooleanField(), + } + ) + } + ) status = fields.KeywordField() is_update = fields.BooleanField()