Skip to content

[Feature] Optional SEARCH_GOOGLE_BASE_URL for the Google search provider #374

Open

Description

@Specstreamai

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_URL unset, the Google provider calls https://www.googleapis.com/customsearch/v1 with the same params as today
  • With it set, in env or in the google search 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.py covers both cases with a mocked requests.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions