Skip to content
Back to top
View this page
Edit this page

# Answerer Development

The answerers give instant answers related to the search query, they usually provide answers of type `Answer`.

Here is an example of a very simple answerer that adds a “Hello” into the answer area:

    from flask_babel import gettext as _
    from searx.answerers import Answerer
    from searx.result_types import Answer

    class MyAnswerer(Answerer):

        keywords = [ "hello", "hello world" ]

        def info(self):
            return AnswererInfo(name=_("Hello"), description=_("lorem .."), keywords=self.keywords)

        def answer(self, request, search):
            return [ Answer(answer="Hello") ]

class searx.answerers.Answerer

  Abstract base class of answerers.

  keywords: list [ str ]

    Keywords to which the answerer has answers.

  abstractmethod answer(query: str ) → list [ BaseAnswer ]

    Function that returns a list of answers to the question/query.

  abstractmethod info() → AnswererInfo

    Information about the answerer, see `AnswererInfo`.

class searx.answerers.AnswererInfo(name: str, description: str, examples: list [ str ], keywords: list [ str ])

  Object that holds information about an answerer, these infos are shown to the user in the Preferences menu.

  To be able to translate the information into other languages, the text must be written in English and translated with `flask_babel.gettext`.

  name: str

    Name of the answerer.

  description: str

    Short description of the answerer.

  examples: list [ str ]

    List of short examples of the usage / of query terms.

  keywords: list [ str ]

    See `Answerer.keywords`

class searx.answerers.AnswerStorage

  A storage for managing the answerers of SearXNG. With the `AnswerStorage.ask`” method, a caller can ask questions to all answerers and receives a list of the results.

  answerer_list: set [ Answerer ]

    The list of `Answerer` in this storage.

  load_builtins()

    Loads `answerer.py` modules from the python packages in git://searx/answerers. The python modules are wrapped by `ModuleAnswerer`.

  register_by_fqn(fqn: str )

    Register a `Answerer` via its fully qualified class namen(FQN).

  register(answerer: Answerer )

    Register a `Answerer`.

  ask(query: str ) → list [ BaseAnswer ]

    An answerer is identified via keywords, if there is a keyword at the first position in the `query` for which there is one or more answerers, then these are called, whereby the entire `query` is passed as argument to the answerer function.

class searx.answerers._core.ModuleAnswerer(mod)

  Bases: `Answerer`

  A wrapper class for legacy answerers where the names (keywords, answer, info) are implemented on the module level (not in a class).

  Note

  For internal use only!

  answer(query: str ) → list [ BaseAnswer ]

    Function that returns a list of answers to the question/query.

  info() → AnswererInfo

    Information about the answerer, see `AnswererInfo`.