diff --git a/bothub/common/models.py b/bothub/common/models.py index 280befa2..54540f59 100644 --- a/bothub/common/models.py +++ b/bothub/common/models.py @@ -15,6 +15,7 @@ from django.utils.translation import ugettext_lazy as _ from django_elasticsearch_dsl_drf.wrappers import dict_to_obj from elasticsearch_dsl import A +from elasticsearch_dsl import Q as elasticQ from rest_framework import status from rest_framework.exceptions import APIException @@ -1108,7 +1109,13 @@ def _search_weak_intents_and_entities(self): def _does_all_examples_have_intents(self): from bothub.common.documents import RepositoryExampleDocument - search = RepositoryExampleDocument.search().query("match", intent_text="") + search = RepositoryExampleDocument.search().query( + "bool", + must=[ + elasticQ("match", intent__text__raw=""), + elasticQ("match", repository_version_language__pk=self.pk), + ], + ) return False if search.execute().hits.total.value != 0 else True @property diff --git a/bothub/common/tests.py b/bothub/common/tests.py index 6aa1455b..8b72ba04 100644 --- a/bothub/common/tests.py +++ b/bothub/common/tests.py @@ -959,6 +959,7 @@ def test_empty_intent(self): RepositoryExampleEntity.objects.create( repository_example=example, start=0, end=7, entity="name" ) + self.assertFalse(self.repository.current_version().ready_for_train) def test_intent_dont_have_min_examples(self):