Search processors

Abstract processor class

Abstract base classes for all engine processors.

class searx.search.processors.abstract.RequestParams[source]

Basic quantity of the Request parameters of all engine types.

query: str

Search term, stripped of search syntax arguments.

category: str

Current category, like general.

Hint

This field is deprecated, don’t use it in further implementations.

This field is currently arbitrarily filled with the name of “one”” category (the name of the first category of the engine). In practice, however, it is not clear what this “one” category should be; in principle, multiple categories can also be activated in a search.

pageno: int

Current page number, where the first page is 1.

safesearch: Literal[0, 1, 2]

Safe-Search filter (0:normal, 1:moderate, 2:strict).

time_range: Literal['day', 'week', 'month', 'year'] | None

Time-range filter.

engine_data: dict[str, str]

Allows the transfer of (engine specific) data to the next request of the client. In the case of the online engines, this data is delivered to the client via the HTML <form> in response.

If the client then sends this form back to the server with the next request, this data will be available.

This makes it possible to carry data from one request to the next without a session context, but this feature (is fragile) and should only be used in exceptional cases. See also engine_data_form.

searxng_locale: str

Language / locale filter from the search request, a string like ‘all’, ‘en’, ‘en-US’, ‘zh-HK’ .. and others, for more details see searx.locales.

class searx.search.processors.abstract.SuspendedStatus[source]

Class to handle suspend state.

class searx.search.processors.abstract.EngineProcessor(engine: Engine | types.ModuleType)[source]

Base classes used for all types of request processors.

initialize(callback: Callable[[EngineProcessor, bool], bool])[source]

Initialization of this EngineProcessor.

If processor’s engine has an init method, it is called first. Engine’s init method is executed in a thread, meaning that the registration (the callback) may occur later and is not already established by the return from this registration method.

Registration only takes place if the init method is not available or is successfully run through.

get_params(search_query: SearchQuery, engine_category: str) RequestParams | None[source]

Returns a dictionary with the request parameters (RequestParams), if the search condition is not supported by the engine, None is returned:

  • time range filter in search conditions, but the engine does not have

    a corresponding filter

  • page number > 1 when engine does not support paging

  • page number > max_page

Offline processor

Processors for engine-type: offline

class searx.search.processors.offline.OfflineProcessor(engine: Engine | types.ModuleType)[source]

Processor class used by offline engines.

Online processor

Processor used for online engines.

class searx.search.processors.online.OnlineProcessor(engine: Engine | types.ModuleType)[source]

Processor class for online engines.

init_engine() bool[source]

This method is called in a thread, and before the base method is called, the network must be set up for the online engines.

get_params(search_query: SearchQuery, engine_category: str) OnlineParams | None[source]

Returns a dictionary with the request params (OnlineParams), if the search condition is not supported by the engine, None is returned.

class searx.search.processors.online.OnlineParams[source]

Request parameters of a online engine.

Online currency processor

Processor used for online_currency engines.

searx.search.processors.online_currency.search_syntax = re.compile('.*?(\\d+(?:\\.\\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.IGNORECASE)

Search syntax used for from/to currency (e.g. 10 usd to eur)

class searx.search.processors.online_currency.CurrenciesParams[source]

Currencies request parameters.

amount: float

Currency amount to be converted

to_iso4217: str

ISO_4217 alpha code of the currency used as the basis for conversion.

from_iso4217: str

ISO_4217 alpha code of the currency to be converted.

from_name: str

Name of the currency used as the basis for conversion.

to_name: str

Name of the currency of the currency to be converted.

class searx.search.processors.online_currency.OnlineCurrenciesParams[source]

Request parameters of a online_currency engine.

class searx.search.processors.online_currency.OnlineCurrencyProcessor(engine: Engine | types.ModuleType)[source]

Processor class used by online_currency engines.

get_params(search_query: SearchQuery, engine_category: str) OnlineCurrenciesParams | None[source]

Returns a dictionary with the request params (OnlineCurrenciesParams). None is returned if the search query does not match search_syntax.

Online dictionary processor

Processor used for online_dictionary engines.

searx.search.processors.online_dictionary.search_syntax = re.compile('.*?([a-z]+)-([a-z]+) (.+)$', re.IGNORECASE)

Search syntax used for from/to language (e.g. en-de)

searx.search.processors.online_dictionary.FromToType

Type of a language descriptions in the context of a online_dictionary.

alias of tuple[bool, str, str]

class searx.search.processors.online_dictionary.DictParams[source]

Dictionary request parameters.

from_lang: tuple[bool, str, str]

Language from which is to be translated.

to_lang: tuple[bool, str, str]

Language to translate into.

query: str

Search term, cleaned of search syntax (from-to has been removed).

class searx.search.processors.online_dictionary.OnlineDictParams[source]

Request parameters of a online_dictionary engine.

class searx.search.processors.online_dictionary.OnlineDictionaryProcessor(engine: Engine | types.ModuleType)[source]

Processor class for online_dictionary engines.

get_params(search_query: SearchQuery, engine_category: str) OnlineDictParams | None[source]

Returns a dictionary with the request params (OnlineDictParams). None is returned if the search query does not match search_syntax.