offline_engines.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .. _offline engines:
  2. ===============
  3. Offline Engines
  4. ===============
  5. .. sidebar:: offline engines
  6. - :ref:`demo offline engine`
  7. - :ref:`sql engines`
  8. - :ref:`engine command`
  9. - :origin:`Redis <searx/engines/redis_server.py>`
  10. To extend the functionality of SearXNG, offline engines are going to be
  11. introduced. An offline engine is an engine which does not need Internet
  12. connection to perform a search and does not use HTTP to communicate.
  13. Offline engines can be configured, by adding those to the `engines` list of
  14. :origin:`settings.yml <searx/settings.yml>`. An example skeleton for offline
  15. engines can be found in :ref:`demo offline engine` (:origin:`demo_offline.py
  16. <searx/engines/demo_offline.py>`).
  17. Programming Interface
  18. =====================
  19. :py:func:`init(engine_settings=None) <searx.engines.demo_offline.init>`
  20. All offline engines can have their own init function to setup the engine before
  21. accepting requests. The function gets the settings from settings.yml as a
  22. parameter. This function can be omitted, if there is no need to setup anything
  23. in advance.
  24. :py:func:`search(query, params) <searx.engines.demo_offline.searc>`
  25. Each offline engine has a function named ``search``. This function is
  26. responsible to perform a search and return the results in a presentable
  27. format. (Where *presentable* means presentable by the selected result
  28. template.)
  29. The return value is a list of results retrieved by the engine.
  30. Engine representation in ``/config``
  31. If an engine is offline, the attribute ``offline`` is set to ``True``.
  32. .. _offline requirements:
  33. Extra Dependencies
  34. ==================
  35. If an offline engine depends on an external tool, SearXNG does not install it by
  36. default. When an administrator configures such engine and starts the instance,
  37. the process returns an error with the list of missing dependencies. Also,
  38. required dependencies will be added to the comment/description of the engine, so
  39. admins can install packages in advance.
  40. If there is a need to install additional packages in *Python's Virtual
  41. Environment* of your SearXNG instance you need to switch into the environment
  42. (:ref:`searxng-src`) first, for this you can use :ref:`searxng.sh`::
  43. $ sudo utils/searxng.sh instance cmd bash
  44. (searxng-pyenv)$ pip install ...
  45. Private engines (Security)
  46. ==========================
  47. To limit the access to offline engines, if an instance is available publicly,
  48. administrators can set token(s) for each of the :ref:`private engines`. If a
  49. query contains a valid token, then SearXNG performs the requested private
  50. search. If not, requests from an offline engines return errors.
  51. Acknowledgement
  52. ===============
  53. This development was sponsored by `Search and Discovery Fund
  54. <https://nlnet.nl/discovery>`_ of `NLnet Foundation <https://nlnet.nl/>`_ .