searxng/docs/dev/offline_engines.rst
Markus Heiser 274288ea99 [docs] revision of the article "Offline engines"
This patch is a a complete revision of the article "Offline engines", which also
merges the content from the searx-wiki [1] into this article.

[1] https://github.com/searx/searx/wiki/Offline-engines

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2021-06-04 15:04:38 +02:00

2.7 KiB

Offline Engines

offline engines

  • demo offline engine
  • sql engines
  • command line engines
  • Redis <searx/engines/redis_server.py>

To extend the functionality of SearxNG, offline engines are going to be introduced. An offline engine is an engine which does not need Internet connection to perform a search and does not use HTTP to communicate.

Offline engines can be configured, by adding those to the engines list of settings.yml <searx/settings.yml>. An example skeleton for offline engines can be found in demo offline engine (demo_offline.py <searx/engines/demo_offline.py>).

Programming Interface

:pyinit(engine_settings=None) <searx.engines.demo_offline.init>

All offline engines can have their own init function to setup the engine before accepting requests. The function gets the settings from settings.yml as a parameter. This function can be omitted, if there is no need to setup anything in advance.

:pysearch(query, params) <searx.engines.demo_offline.searc>

Each offline engine has a function named search. This function is responsible to perform a search and return the results in a presentable format. (Where presentable means presentable by the selected result template.)

The return value is a list of results retrieved by the engine.

Engine representation in /config

If an engine is offline, the attribute offline is set to True.

Extra Dependencies

If an offline engine depends on an external tool, SearxNG does not install it by default. When an administrator configures such engine and starts the instance, the process returns an error with the list of missing dependencies. Also, required dependencies will be added to the comment/description of the engine, so admins can install packages in advance.

If there is a need to install additional packages in Python's Virtual Environment of your SearxNG instance you need to switch into the environment (searx-src) first, for this you can use searx.sh:

$ sudo utils/searx.sh shell
(searx-pyenv)$ pip install ...

Private engines (Security)

To limit the access to offline engines, if an instance is available publicly, administrators can set token(s) for each of the private engines. If a query contains a valid token, then SearxNG performs the requested private search. If not, requests from an offline engines return errors.

Acknowledgement

This development was sponsored by Search and Discovery Fund of NLnet Foundation .