Skip to content

Commit f90687b

Browse files
committed
OpenConceptLab/ocl_issues#2238 | updated threshold score to match against percentile score (normalized) | added medium match type if any highlights are there
1 parent a451bec commit f90687b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/concepts/views.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,8 @@ def post(request):
780780

781781
class MetadataToConceptsListView(BaseAPIView): # pragma: no cover
782782
default_limit = 1
783-
score_threshold = 5
784-
score_threshold_semantic_very_high = 1.64
783+
score_threshold = 0.9
784+
score_threshold_semantic_very_high = 0.9
785785
serializer_class = ConceptListSerializer
786786
permission_classes = (IsAuthenticatedOrReadOnly,)
787787
es_fields = Concept.es_fields
@@ -845,13 +845,15 @@ def filter_queryset(self, _=None): # pylint:disable=too-many-locals,too-many-st
845845
if limit > 1:
846846
concept._match_type = 'low' # pylint:disable=protected-access
847847
score_to_check = normalized_score if normalized_score is not None else score
848-
if concept._highlight.get('name', None) or is_semantic and score_to_check > score_threshold: # pylint:disable=protected-access
848+
if concept._highlight.get('name', None) or (is_semantic and score_to_check >= score_threshold): # pylint:disable=protected-access
849849
concept._match_type = 'very_high' # pylint:disable=protected-access
850850
elif concept._highlight.get('synonyms', None): # pylint:disable=protected-access
851851
concept._match_type = 'high' # pylint:disable=protected-access
852+
elif concept._highlight: # pylint:disable=protected-access
853+
concept._match_type = 'medium' # pylint:disable=protected-access
852854
else:
853855
concept._match_type = 'very_high' # pylint:disable=protected-access
854-
if not best_match or concept._match_type in ['high', 'very_high']: # pylint:disable=protected-access
856+
if not best_match or concept._match_type in ['medium', 'high', 'very_high']: # pylint:disable=protected-access
855857
serializer = ConceptDetailSerializer if self.is_verbose() else ConceptMinimalSerializer
856858
data = serializer(concept, context={'request': self.request}).data
857859
data['search_meta']['search_normalized_score'] = normalized_score * 100

0 commit comments

Comments
 (0)