@@ -564,7 +564,7 @@ def _cardsearch_handle(
564564 _results .append (CardsearchResult (
565565 card_iri = _card_iri ,
566566 card_pk = _es8_hit ['_id' ],
567- text_match_evidence = list (self ._gather_textmatch_evidence (_card_iri , _es8_hit )),
567+ text_match_evidence = list (self ._gather_textmatch_evidence (_card_iri , _es8_hit , cardsearch_params )),
568568 ))
569569 _relatedproperty_list : list [PropertypathUsage ] = []
570570 if cardsearch_params .related_property_paths :
@@ -585,16 +585,20 @@ def _cardsearch_handle(
585585 search_params = cardsearch_params ,
586586 )
587587
588- def _gather_textmatch_evidence (self , card_iri , es8_hit ) -> Iterator [TextMatchEvidence ]:
588+ def _gather_textmatch_evidence (self , card_iri , es8_hit , cardsearch_params ) -> Iterator [TextMatchEvidence ]:
589589 for _field , _snippets in es8_hit .get ('highlight' , {}).items ():
590590 (_ , _ , _encoded_path ) = _field .rpartition ('.' )
591591 _property_path = _parse_path_field_name (_encoded_path )
592- for _snippet in _snippets :
593- yield TextMatchEvidence (
594- property_path = _property_path ,
595- matching_highlight = rdf .literal (_snippet ),
596- card_iri = card_iri ,
597- )
592+ if ( # skip highlights on non-requested text fields
593+ _property_path in cardsearch_params .cardsearch_text_paths
594+ or len (_property_path ) in cardsearch_params .cardsearch_text_glob_depths
595+ ):
596+ for _snippet in _snippets :
597+ yield TextMatchEvidence (
598+ property_path = _property_path ,
599+ matching_highlight = rdf .literal (_snippet ),
600+ card_iri = card_iri ,
601+ )
598602
599603
600604###
0 commit comments