Answer Results

Typification of the answer results. Results of this type are rendered in the answers.html template.


class searx.result_types.answer.BaseAnswer(*, url: str | None = None, template: str = 'default.html', engine: str | None = '', parsed_url: ParseResult | None = None)[source]

Bases: Result

Base class of all answer types. It is not intended to build instances of this class (aka abstract).

class searx.result_types.answer.Answer(*, url: str | None = None, template: str = 'answer/legacy.html', engine: str | None = '', parsed_url: ParseResult | None = None, answer: str)[source]

Bases: BaseAnswer

Simple answer type where the answer is a simple string with an optional url field field to link a resource (article, map, ..) related to the answer.

answer: str

Text of the answer.

class searx.result_types.answer.Translations(*, url: str | None = None, template: str = 'answer/translations.html', engine: str | None = '', parsed_url: ParseResult | None = None, translations: list[Item])[source]

Bases: BaseAnswer

Answer type with a list of translations.

The items in the list of Translations.translations are of type Translations.Item:

def response(resp):
    results = []
    ...
    foo_1 = Translations.Item(
        text="foobar",
        synonyms=["bar", "foo"],
        examples=["foo and bar are placeholders"],
    )
    foo_url="https://www.deepl.com/de/translator#en/de/foo"
    ...
    Translations(results=results, translations=[foo], url=foo_url)
translations: list[Translations.Item]

List of translations.

class Item(*, text: str, transliteration: str = '', examples: list[str] = <factory>, definitions: list[str] = <factory>, synonyms: list[str] = <factory>)[source]

Bases: Struct

A single element of the translations / a translation. A translation consists of at least a mandatory text property (the translation) , optional properties such as definitions, synonyms and examples are possible.

text: str

Translated text.

transliteration: str

Transliteration of the requested translation.

examples: list[str]

List of examples for the requested translation.

definitions: list[str]

List of definitions for the requested translation.

synonyms: list[str]

List of synonyms for the requested translation.

class searx.result_types.answer.AnswerSet[source]

Bases: object

Aggregator for BaseAnswer items in a result container.