From 2b73daea10b1943344bd7c7c99c0611fc5cd1c08 Mon Sep 17 00:00:00 2001 From: helllllllder Date: Fri, 15 Oct 2021 16:15:48 -0300 Subject: [PATCH 1/2] add NestedFilteringFilterBackend in RepositoryNLPLogViewSet --- bothub/api/v2/repository/views.py | 17 ++++++++++++++--- bothub/settings.py | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bothub/api/v2/repository/views.py b/bothub/api/v2/repository/views.py index 8a0453789..46a64aa00 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), ) From 03cc1b9df95d87786d3f7e68ed62c375a2d9f775 Mon Sep 17 00:00:00 2001 From: helllllllder Date: Mon, 18 Oct 2021 10:54:14 -0300 Subject: [PATCH 2/2] flake8 --- bothub/api/v2/repository/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bothub/api/v2/repository/views.py b/bothub/api/v2/repository/views.py index 46a64aa00..454fbf37e 100644 --- a/bothub/api/v2/repository/views.py +++ b/bothub/api/v2/repository/views.py @@ -1168,8 +1168,8 @@ class RepositoryNLPLogViewSet(DocumentViewSet): "repository_version": "repository_version", "repository_version_language": "repository_version_language", } - nested_filter_fields= { - "intent":{ + nested_filter_fields = { + "intent": { "field": "nlp_log.intent.name.raw", "path": "nlp_log", },