diff --git a/bothub/api/v2/repository/views.py b/bothub/api/v2/repository/views.py index 8a0453789..454fbf37e 100644 --- a/bothub/api/v2/repository/views.py +++ b/bothub/api/v2/repository/views.py @@ -10,6 +10,7 @@ from django_elasticsearch_dsl_drf.filter_backends import ( CompoundSearchFilterBackend, FilteringFilterBackend, + NestedFilteringFilterBackend, ) from django_elasticsearch_dsl_drf.pagination import LimitOffsetPagination from django_elasticsearch_dsl_drf.viewsets import DocumentViewSet @@ -1153,7 +1154,11 @@ class RepositoryNLPLogViewSet(DocumentViewSet): serializer_class = RepositoryNLPLogSerializer lookup_field = "pk" permission_classes = [permissions.IsAuthenticated, RepositoryLogPermission] - filter_backends = [CompoundSearchFilterBackend, FilteringFilterBackend] + filter_backends = [ + CompoundSearchFilterBackend, + FilteringFilterBackend, + NestedFilteringFilterBackend, + ] pagination_class = LimitOffsetPagination limit = settings.REPOSITORY_NLP_LOG_LIMIT search_fields = ["text"] @@ -1162,9 +1167,15 @@ class RepositoryNLPLogViewSet(DocumentViewSet): "language": "language", "repository_version": "repository_version", "repository_version_language": "repository_version_language", - "intent": "log_intent.intent", + } + nested_filter_fields = { + "intent": { + "field": "nlp_log.intent.name.raw", + "path": "nlp_log", + }, "confidence": { - "field": "log_intent.confidence", + "field": "nlp_log.intent.confidence", + "path": "nlp_log", "lookups": [LOOKUP_QUERY_LTE, LOOKUP_QUERY_GTE], }, } diff --git a/bothub/settings.py b/bothub/settings.py index ee234f3f0..ce5afcb04 100644 --- a/bothub/settings.py +++ b/bothub/settings.py @@ -81,7 +81,7 @@ ELASTICSEARCH_REPOSITORYNLPLOG_INDEX=(str, "ai_repositorynlplog"), ELASTICSEARCH_REPOSITORYQANLPLOG_INDEX=(str, "ai_repositoryqanlplog"), ELASTICSEARCH_NUMBER_OF_SHARDS=(int, 1), - ELASTICSEARCH_NUMBER_OF_REPLICAS=(int, 1), + ELASTICSEARCH_NUMBER_OF_REPLICAS=(int, 0), ELASTICSEARCH_SIGNAL_PROCESSOR=(str, "realtime"), GUNICORN_WORKERS=(int, multiprocessing.cpu_count() * 2 + 1), )