Result¶
Basic types for the typification of results.
Resultbase classLegacyResultfor internal use only
- class searx.result_types._base.Result(*, url: str | None = None, engine: str | None = '', parsed_url: ParseResult | None = None)[source]¶
Base class of all result types Result Types.
- engine: str | None¶
Name of the engine this result comes from. In case of plugins a prefix
plugin:is set, in case of answerer prefixanswerer:is set.The field is optional and is initialized from the context if necessary.
- parsed_url: ParseResult | None¶
urllib.parse.ParseResultofResult.url.The field is optional and is initialized from the context if necessary.
- normalize_result_fields()[source]¶
Normalize fields
urlandparse_sql.If field
urlis set and fieldparse_urlis unset, initparse_urlfrom fieldurl. Theurlfield is initialized with the resulting value inparse_url, ifurlandparse_urlare not equal.
- filter_urls(filter_func: Callable[[Result | LegacyResult, str, str], str | bool])[source]¶
A filter function is passed in the
filter_funcargument to filter and/or modify the URLs.The filter function receives the
result objectas the first argument and the field name (str) in the second argument. In the third argument the URL string value is passed to the filter function.The filter function is applied to all fields that contain a URL, in addition to the familiar
urlfield, these include fields such as:["url", "iframe_src", "audio_src", "img_src", "thumbnail_src", "thumbnail"]
and the
urlslist of items of the infobox.For each field, the filter function is called and returns a bool or a string value:
True: leave URL in field unchangedFalse: remove URL field from result (or remove entire result)str: modified URL to be used instead
See Filter URLs example.
- class searx.result_types._base.LegacyResult(*args: Any, **kwargs: Any)[source]¶
A wrapper around a legacy result item. The SearXNG core uses this class for untyped dictionaries / to be downward compatible.
This class is needed until we have implemented an
Resultclass for each result type and the old usages in the codebase have been fully migrated.There is only one place where this class is used, in the
searx.results.ResultContainer.Attention
Do not use this class in your own implementations!