Repository navigation
Description
Problem or motivation
GoogleSearchProvider._do_search sends its request to https://www.googleapis.com/customsearch/v1, a literal in backend_api_python/app/services/search.py:295. Only SEARCH_GOOGLE_API_KEY and SEARCH_GOOGLE_CX can be set. Google's overview page says "Existing Custom Search JSON API customers have until January 1, 2027 to transition to an alternative solution" (https://developers.google.com/custom-search/v1/overview), so from that date the google provider fails for every install that uses it and there's no setting to change.
#290 proposes a new Serply provider for the same date. This one is smaller and adds no provider: it keeps the Google provider and makes its address a setting.
Proposed solution
An optional SEARCH_GOOGLE_BASE_URL, read with self._search_config_value('google', 'base_url', 'SEARCH_GOOGLE_BASE_URL') like the key and CX at search.py:709-710 and :737-738, defaulting to https://www.googleapis.com/customsearch/v1 and passed to GoogleSearchProvider. Settings get a text field next to SEARCH_GOOGLE_CX in routes/settings.py with the Google URL as its default, as GDELT_BASE_URL has, and env.example gets SEARCH_GOOGLE_BASE_URL= under SEARCH_GOOGLE_CX. Params, the 429 quota handling and result parsing stay as they are.
Alternatives considered
Leaving it as it is means the google provider stops working on January 1, 2027. A new provider per replacement service is what #290 asks for. A base URL works with any service that takes the same Custom Search parameters, and with no setting the request doesn't change.
Acceptance criteria
- With
SEARCH_GOOGLE_BASE_URLunset, the Google provider callshttps://www.googleapis.com/customsearch/v1with the same params as today - With it set, in env or in the
googlesearch config, the provider calls that URL - The settings page shows the field under the Google CX field
- A test in
tests/test_search_service_routing.pycovers both cases with a mockedrequests.get
If you confirm the scope, I can send the PR.
I run a search API that answers in the Custom Search JSON format, which is how I ran into the date.
Activity