settings_engines.rst 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. .. _settings engines:
  2. ============
  3. ``engines:``
  4. ============
  5. .. sidebar:: Further reading ..
  6. - :ref:`configured engines`
  7. - :ref:`engines-dev`
  8. In the section ``engines:`` is a list of the engines that are to be made
  9. available in the instance. Each list entry is in turn a key/value mapping.
  10. .. code:: yaml
  11. engines:
  12. - name: dummy.online
  13. engine: dummy
  14. ..
  15. - name: dummy.offline
  16. engine: dummy-offline
  17. ..
  18. ..
  19. In the code example below a *full fledged* example of a YAML setup from a dummy
  20. engine is shown. Most of the options have a default value or even are optional.
  21. .. hint::
  22. A few more options are possible, but they are pretty specific to some
  23. engines (:ref:`engine implementations`).
  24. .. code:: yaml
  25. - name: example
  26. engine: example
  27. shortcut: demo
  28. base_url: 'https://{language}.example.com/'
  29. send_accept_language_header: false
  30. categories: general
  31. timeout: 3.0
  32. api_key: 'apikey'
  33. disabled: false
  34. language: en_US
  35. tokens: [ 'my-secret-token' ]
  36. weight: 1
  37. display_error_messages: true
  38. about:
  39. website: https://example.com
  40. wikidata_id: Q306656
  41. official_api_documentation: https://example.com/api-doc
  42. use_official_api: true
  43. require_api_key: true
  44. results: HTML
  45. # overwrite values from section 'outgoing:'
  46. enable_http2: false
  47. retries: 1
  48. max_connections: 100
  49. max_keepalive_connections: 10
  50. keepalive_expiry: 5.0
  51. using_tor_proxy: false
  52. proxies:
  53. http:
  54. - http://proxy1:8080
  55. - http://proxy2:8080
  56. https:
  57. - http://proxy1:8080
  58. - http://proxy2:8080
  59. - socks5://user:password@proxy3:1080
  60. - socks5h://user:password@proxy4:1080
  61. # other network settings
  62. enable_http: false
  63. retry_on_http_error: true # or 403 or [404, 429]
  64. ``name`` :
  65. Name that will be used across SearXNG to define this engine. In settings, on
  66. the result page...
  67. ``engine`` :
  68. Name of the python file used to handle requests and responses to and from this
  69. search engine.
  70. ``shortcut`` :
  71. Code used to execute bang requests (in this case using ``!bi``)
  72. ``base_url`` : optional
  73. Part of the URL that should be stable across every request. Can be useful to
  74. use multiple sites using only one engine, or updating the site URL without
  75. touching at the code.
  76. ``send_accept_language_header`` :
  77. Several engines that support languages (or regions) deal with the HTTP header
  78. ``Accept-Language`` to build a response that fits to the locale. When this
  79. option is activated, the language (locale) that is selected by the user is used
  80. to build and send a ``Accept-Language`` header in the request to the origin
  81. search engine.
  82. .. _engine categories:
  83. ``categories`` : optional
  84. Specifies to which categories the engine should be added. Engines can be
  85. assigned to multiple categories.
  86. Categories can be shown as tabs (:ref:`settings categories_as_tabs`) in the
  87. UI. A search in a tab (in the UI) will query all engines that are active in
  88. this tab. In the preferences page (``/preferences``) -- under *engines* --
  89. users can select what engine should be active when querying in this tab.
  90. Alternatively, :ref:`\!bang <search-syntax>` can be used to search all engines
  91. in a category, regardless of whether they are active or not, or whether they
  92. are in a tab of the UI or not. For example, ``!dictionaries`` can be used to
  93. query all search engines in that category (group).
  94. ``timeout`` : optional
  95. Timeout of the search with the current search engine. Overwrites
  96. ``request_timeout`` from :ref:`settings outgoing`. **Be careful, it will
  97. modify the global timeout of SearXNG.**
  98. ``api_key`` : optional
  99. In a few cases, using an API needs the use of a secret key. How to obtain them
  100. is described in the file.
  101. ``disabled`` : optional
  102. To disable by default the engine, but not deleting it. It will allow the user
  103. to manually activate it in the settings.
  104. ``inactive``: optional
  105. Remove the engine from the settings (*disabled & removed*).
  106. ``language`` : optional
  107. If you want to use another language for a specific engine, you can define it
  108. by using the ISO code of language (and region), like ``fr``, ``en-US``,
  109. ``de-DE``.
  110. ``tokens`` : optional
  111. A list of secret tokens to make this engine *private*, more details see
  112. :ref:`private engines`.
  113. ``weight`` : default ``1``
  114. Weighting of the results of this engine.
  115. ``display_error_messages`` : default ``true``
  116. When an engine returns an error, the message is displayed on the user interface.
  117. ``network`` : optional
  118. Use the network configuration from another engine.
  119. In addition, there are two default networks:
  120. - ``ipv4`` set ``local_addresses`` to ``0.0.0.0`` (use only IPv4 local addresses)
  121. - ``ipv6`` set ``local_addresses`` to ``::`` (use only IPv6 local addresses)
  122. ``enable_http`` : optional
  123. Enable HTTP for this engine (by default only HTTPS is enabled).
  124. ``retry_on_http_error`` : optional
  125. Retry request on some HTTP status code.
  126. Example:
  127. * ``true`` : on HTTP status code between 400 and 599.
  128. * ``403`` : on HTTP status code 403.
  129. * ``[403, 429]``: on HTTP status code 403 and 429.
  130. ``proxies`` :
  131. Overwrites proxy settings from :ref:`settings outgoing`.
  132. ``using_tor_proxy`` :
  133. Using tor proxy (``true``) or not (``false``) for this engine. The default is
  134. taken from ``using_tor_proxy`` of the :ref:`settings outgoing`.
  135. .. _Pool limit configuration: https://www.python-httpx.org/advanced/#pool-limit-configuration
  136. ``max_keepalive_connection#s`` :
  137. `Pool limit configuration`_, overwrites value ``pool_maxsize`` from
  138. :ref:`settings outgoing` for this engine.
  139. ``max_connections`` :
  140. `Pool limit configuration`_, overwrites value ``pool_connections`` from
  141. :ref:`settings outgoing` for this engine.
  142. ``keepalive_expiry`` :
  143. `Pool limit configuration`_, overwrites value ``keepalive_expiry`` from
  144. :ref:`settings outgoing` for this engine.
  145. .. _private engines:
  146. Private Engines (``tokens``)
  147. ============================
  148. Administrators might find themselves wanting to limit access to some of the
  149. enabled engines on their instances. It might be because they do not want to
  150. expose some private information through :ref:`offline engines`. Or they would
  151. rather share engines only with their trusted friends or colleagues.
  152. .. sidebar:: info
  153. Initial sponsored by `Search and Discovery Fund
  154. <https://nlnet.nl/discovery>`_ of `NLnet Foundation <https://nlnet.nl/>`_.
  155. To solve this issue the concept of *private engines* exists.
  156. A new option was added to engines named `tokens`. It expects a list of strings.
  157. If the user making a request presents one of the tokens of an engine, they can
  158. access information about the engine and make search requests.
  159. Example configuration to restrict access to the Arch Linux Wiki engine:
  160. .. code:: yaml
  161. - name: arch linux wiki
  162. engine: archlinux
  163. shortcut: al
  164. tokens: [ 'my-secret-token' ]
  165. Unless a user has configured the right token, the engine is going to be hidden
  166. from them. It is not going to be included in the list of engines on the
  167. Preferences page and in the output of `/config` REST API call.
  168. Tokens can be added to one's configuration on the Preferences page under "Engine
  169. tokens". The input expects a comma separated list of strings.
  170. The distribution of the tokens from the administrator to the users is not carved
  171. in stone. As providing access to such engines implies that the admin knows and
  172. trusts the user, we do not see necessary to come up with a strict process.
  173. Instead, we would like to add guidelines to the documentation of the feature.
  174. Example: Multilingual Search
  175. ============================
  176. SearXNG does not support true multilingual search. You have to use the language
  177. prefix in your search query when searching in a different language.
  178. But there is a workaround: By adding a new search engine with a different
  179. language, SearXNG will search in your default and other language.
  180. Example configuration in settings.yml for a German and English speaker:
  181. .. code-block:: yaml
  182. search:
  183. default_lang : "de"
  184. ...
  185. engines:
  186. - name : google english
  187. engine : google
  188. language : en
  189. ...
  190. When searching, the default google engine will return German results and
  191. "google english" will return English results.