diff --git a/server/routes/shared_api/autocomplete/helpers.py b/server/routes/shared_api/autocomplete/helpers.py index 4a87ff5372..204b2ca084 100644 --- a/server/routes/shared_api/autocomplete/helpers.py +++ b/server/routes/shared_api/autocomplete/helpers.py @@ -57,6 +57,9 @@ 'place_dcid': 'asia' }] + TWO_WORD_CUSTOM_PLACES +# Exceptions for the 3 letter trigger rule. These queries can trigger on only two letters. +TWO_LETTER_TRIGGERS = {"us"} + def find_queries(user_query: str) -> List[str]: """Extracts subqueries to send to the Google Maps Predictions API from the entire user input. @@ -78,8 +81,9 @@ def find_queries(user_query: str) -> List[str]: else: cumulative = word - # Only send queries 3 characters or longer. - if (len(cumulative) >= MIN_CHARACTERS_PER_QUERY): + # Only send queries 3 characters or longer, except for the exceptions in TWO_LETTER_TRIGGERS. + if (len(cumulative) >= MIN_CHARACTERS_PER_QUERY or + (len(cumulative) == 2 and cumulative.lower() in TWO_LETTER_TRIGGERS)): queries.append(cumulative) # Start by running the longer queries.