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.
url: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)
: A link related to this *result*
engine: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)
: Name of the engine *this* result comes from. In case of *plugins* a
prefix `plugin:` is set, in case of *answerer* prefix `answerer:` is
set.
The field is optional and is initialized from the context if necessary.
parsed\_url: [ParseResult](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.ParseResult) | [None](https://docs.python.org/3/builtins/constants.html#None)
: [`urllib.parse.ParseResult`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.ParseResult) of [`Result.url`](#searx.result_types._base.Result.url).
The field is optional and is initialized from the context if necessary.
normalize\_result\_fields()[[source]](https://docs.searxng.org/_modules/searx/result_types/_base.html#Result.normalize_result_fields)
: Normalize fields `url` and `parse_sql`.
- If field `url` is set and field `parse_url` is unset, init
`parse_url` from field `url`. The `url` field is initialized
with the resulting value in `parse_url`, if `url` and
`parse_url` are not equal.
filter\_urls(*filter\_func: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[Result](#searx.result_types._base.Result) | [LegacyResult](#searx.result_types._base.LegacyResult), [str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str)], [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [bool](https://docs.python.org/3/builtins/functions.html#bool)]*)[[source]](https://docs.searxng.org/_modules/searx/result_types/_base.html#Result.filter_urls)
: A filter function is passed in the `filter_func` argument to
filter and/or modify the URLs.
The filter function receives the [`result object`](#searx.result_types._base.Result) as
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 `url` field, these include fields such as:
```
["url", "iframe_src", "audio_src", "img_src", "thumbnail_src", "thumbnail"]
```
and the `urls` list 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 unchanged
- `False`: remove URL field from result (or remove entire result)
- `str`: modified URL to be used instead
See [Filter URLs example](https://docs.searxng.org/dev/plugins/development.html#filter-urls-example).
defaults\_from(*other: [Result](#searx.result_types._base.Result)*)[[source]](https://docs.searxng.org/_modules/searx/result_types/_base.html#Result.defaults_from)
: Fields not set in *self* will be updated from the field values of the
*other*. If a field is set (exists) but contains an empty string
or the value `None`, it is also considered *not set*.
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 [`Result`](#searx.result_types._base.Result) class 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!
filter\_urls(*filter\_func: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[Result](#searx.result_types._base.Result) | [LegacyResult](#searx.result_types._base.LegacyResult), [str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str)], [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [bool](https://docs.python.org/3/builtins/functions.html#bool)]*)[[source]](https://docs.searxng.org/_modules/searx/result_types/_base.html#LegacyResult.filter_urls)
: See [`Result.filter_urls`](#searx.result_types._base.Result.filter_urls)
Copyright © SearXNG team
Made with Furo
