File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 88from openaleph_search .core import get_es
99from openaleph_search .index .mapping import (
1010 DATE_FORMAT ,
11- GROUPS ,
1211 NUMERIC_TYPES ,
1312 Field ,
1413 get_field_type ,
@@ -337,8 +336,19 @@ def get_highlight(self) -> dict[str, Any]:
337336 query = bool_query ()
338337 if self .get_query_string ():
339338 query ["bool" ]["should" ] = [self .get_query_string ()]
339+ # Only highlight filter values that are human-readable text.
340+ # Skip short-code groups (countries, languages, etc.) to avoid
341+ # noisy highlights (e.g. "es" for Spain matching German text).
342+ highlight_groups = {
343+ "names" ,
344+ "addresses" ,
345+ "identifiers" ,
346+ "emails" ,
347+ "ips" ,
348+ "phones" ,
349+ }
340350 for key , values in self .parser .filters .items ():
341- if key in GROUPS or key == Field .NAME :
351+ if key in highlight_groups or key == Field .NAME :
342352 for value in values :
343353 query ["bool" ]["should" ].append (
344354 {
Original file line number Diff line number Diff line change @@ -160,6 +160,7 @@ def test_highlight(self):
160160 "fields" : ["text" ],
161161 "default_operator" : "AND" ,
162162 "minimum_should_match" : "66%" ,
163+ "allow_leading_wildcard" : False ,
163164 }
164165 },
165166 },
You can’t perform that action at this time.
0 commit comments