Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
aggreggations: add faceted
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Jul 31, 2024
1 parent b02a4f7 commit 4ce68a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions backoffice/backoffice/workflows/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

from django.shortcuts import get_object_or_404
from django_elasticsearch_dsl_drf.filter_backends import (
FacetedSearchFilterBackend,
FilteringFilterBackend,
OrderingFilterBackend,
SearchFilterBackend,
)
from django_elasticsearch_dsl_drf.viewsets import BaseDocumentViewSet
from opensearch_dsl import TermsFacet
from rest_framework import status, viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
Expand Down Expand Up @@ -143,6 +145,7 @@ def __init__(self, *args, **kwargs):
pagination_class = OSStandardResultsSetPagination
filter_backends = [
SearchFilterBackend,
FacetedSearchFilterBackend,
FilteringFilterBackend,
OrderingFilterBackend,
]
Expand All @@ -158,5 +161,19 @@ def __init__(self, *args, **kwargs):

ordering = ["-_updated_at"]

faceted_search_fields = {
"status": {
"field": "status",
"facet": TermsFacet,
"options": {
"size": 15,
"order": {
"_key": "asc",
},
},
"enabled": True,
}
}

def get_serializer_class(self):
return WorkflowDocumentSerializer
2 changes: 1 addition & 1 deletion workflows/logs/scheduler/latest

0 comments on commit 4ce68a0

Please sign in to comment.