settings_engine.rst 7.9 KB

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