replaced institution autocompletion logic with wildcards
This commit is contained in:
@@ -99,49 +99,36 @@ class InstitutionsSearchClient:
|
||||
stripped = query_text.strip()
|
||||
|
||||
must.append({
|
||||
"bool": {
|
||||
"should": [
|
||||
# Fast prefix matching via search_as_you_type shingles
|
||||
{
|
||||
"multi_match": {
|
||||
"query": stripped,
|
||||
"type": "bool_prefix",
|
||||
"fields": [
|
||||
"display_name.search",
|
||||
"display_name.search._2gram",
|
||||
"display_name.search._3gram",
|
||||
"display_name_alternatives.search",
|
||||
"display_name_alternatives.search._2gram",
|
||||
],
|
||||
"boost": 2,
|
||||
"bool": {
|
||||
"should": [
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name.keyword": {
|
||||
"value": f"*{stripped}*",
|
||||
"boost": 2
|
||||
}
|
||||
},
|
||||
# Exact acronym match — high confidence signal
|
||||
{
|
||||
"term": {
|
||||
"display_name_acronyms.keyword": {
|
||||
"value": stripped.upper(),
|
||||
"boost": 10,
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name_alternatives.keyword": {
|
||||
"value": f"*{stripped}*",
|
||||
"boost": 2
|
||||
}
|
||||
},
|
||||
# Fuzzy fallback for typos (only worth it for longer input)
|
||||
*(
|
||||
[{
|
||||
"match": {
|
||||
"display_name": {
|
||||
"query": stripped,
|
||||
"fuzziness": "AUTO",
|
||||
"boost": 1,
|
||||
}
|
||||
}
|
||||
}]
|
||||
if len(stripped) >= 4 else []
|
||||
),
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name_acronyms.keyword": {
|
||||
"value": f"*{stripped.upper()}*",
|
||||
"boost": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"minimum_should_match": 1
|
||||
}
|
||||
})
|
||||
|
||||
filter_queries = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user