summaryrefslogtreecommitdiff
path: root/_sources/admin/settings/settings_engine.rst.txt
blob: 454fcd24165f64047bdf24216fa5a801d41f5c45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
.. _settings engine:

===========
``engine:``
===========

.. sidebar:: Further reading ..

   - :ref:`configured engines`
   - :ref:`engines-dev`

In the code example below a *full fledged* example of a YAML setup from a dummy
engine is shown.  Most of the options have a default value or even are optional.

.. hint::

   A few more options are possible, but they are pretty specific to some
   engines (:ref:`engine implementations`).

.. code:: yaml

   - name: example engine
     engine: example
     shortcut: demo
     base_url: 'https://{language}.example.com/'
     send_accept_language_header: false
     categories: general
     timeout: 3.0
     api_key: 'apikey'
     disabled: false
     language: en_US
     tokens: [ 'my-secret-token' ]
     weight: 1
     display_error_messages: true
     about:
        website: https://example.com
        wikidata_id: Q306656
        official_api_documentation: https://example.com/api-doc
        use_official_api: true
        require_api_key: true
        results: HTML

     # overwrite values from section 'outgoing:'
     enable_http2: false
     retries: 1
     max_connections: 100
     max_keepalive_connections: 10
     keepalive_expiry: 5.0
     using_tor_proxy: false
     proxies:
       http:
         - http://proxy1:8080
         - http://proxy2:8080
       https:
         - http://proxy1:8080
         - http://proxy2:8080
         - socks5://user:password@proxy3:1080
         - socks5h://user:password@proxy4:1080

     # other network settings
     enable_http: false
     retry_on_http_error: true # or 403 or [404, 429]


``name`` :
  Name that will be used across SearXNG to define this engine.  In settings, on
  the result page...

``engine`` :
  Name of the python file used to handle requests and responses to and from this
  search engine.

``shortcut`` :
  Code used to execute bang requests (in this case using ``!bi``)

``base_url`` : optional
  Part of the URL that should be stable across every request.  Can be useful to
  use multiple sites using only one engine, or updating the site URL without
  touching at the code.

``send_accept_language_header`` :
  Several engines that support languages (or regions) deal with the HTTP header
  ``Accept-Language`` to build a response that fits to the locale.  When this
  option is activated, the language (locale) that is selected by the user is used
  to build and send a ``Accept-Language`` header in the request to the origin
  search engine.

.. _engine categories:

``categories`` : optional
  Specifies to which categories the engine should be added.  Engines can be
  assigned to multiple categories.

  Categories can be shown as tabs (:ref:`settings categories_as_tabs`) in the
  UI.  A search in a tab (in the UI) will query all engines that are active in
  this tab.  In the preferences page (``/preferences``) -- under *engines* --
  users can select what engine should be active when querying in this tab.

  Alternatively, :ref:`\!bang <search-syntax>` can be used to search all engines
  in a category, regardless of whether they are active or not, or whether they
  are in a tab of the UI or not.  For example, ``!dictionaries`` can be used to
  query all search engines in that category (group).

``timeout`` : optional
  Timeout of the search with the current search engine.  Overwrites
  ``request_timeout`` from :ref:`settings outgoing`.  **Be careful, it will
  modify the global timeout of SearXNG.**

``api_key`` : optional
  In a few cases, using an API needs the use of a secret key.  How to obtain them
  is described in the file.

``disabled`` : optional
  To disable by default the engine, but not deleting it.  It will allow the user
  to manually activate it in the settings.

``inactive``: optional
  Remove the engine from the settings (*disabled & removed*).

``language`` : optional
  If you want to use another language for a specific engine, you can define it
  by using the ISO code of language (and region), like ``fr``, ``en-US``,
  ``de-DE``.

``tokens`` : optional
  A list of secret tokens to make this engine *private*, more details see
  :ref:`private engines`.

``weight`` : default ``1``
  Weighting of the results of this engine.

``display_error_messages`` : default ``true``
  When an engine returns an error, the message is displayed on the user interface.

``network`` : optional
  Use the network configuration from another engine.
  In addition, there are two default networks:

  - ``ipv4`` set ``local_addresses`` to ``0.0.0.0`` (use only IPv4 local addresses)
  - ``ipv6`` set ``local_addresses`` to ``::`` (use only IPv6 local addresses)

``enable_http`` : optional
  Enable HTTP for this engine (by default only HTTPS is enabled).

``retry_on_http_error`` : optional
  Retry request on some HTTP status code.

  Example:

  * ``true`` : on HTTP status code between 400 and 599.
  * ``403`` : on HTTP status code 403.
  * ``[403, 429]``: on HTTP status code 403 and 429.

``proxies`` :
  Overwrites proxy settings from :ref:`settings outgoing`.

``using_tor_proxy`` :
  Using tor proxy (``true``) or not (``false``) for this engine.  The default is
  taken from ``using_tor_proxy`` of the :ref:`settings outgoing`.

.. _Pool limit configuration: https://www.python-httpx.org/advanced/#pool-limit-configuration

``max_keepalive_connection#s`` :
  `Pool limit configuration`_, overwrites value ``pool_maxsize`` from
   :ref:`settings outgoing` for this engine.

``max_connections`` :
  `Pool limit configuration`_, overwrites value ``pool_connections`` from
  :ref:`settings outgoing` for this engine.

``keepalive_expiry`` :
  `Pool limit configuration`_, overwrites value ``keepalive_expiry`` from
  :ref:`settings outgoing` for this engine.


.. _private engines:

Private Engines (``tokens``)
============================

Administrators might find themselves wanting to limit access to some of the
enabled engines on their instances.  It might be because they do not want to
expose some private information through :ref:`offline engines`.  Or they would
rather share engines only with their trusted friends or colleagues.

.. sidebar:: info

   Initial sponsored by `Search and Discovery Fund
   <https://nlnet.nl/discovery>`_ of `NLnet Foundation <https://nlnet.nl/>`_.

To solve this issue the concept of *private engines* exists.

A new option was added to engines named `tokens`.  It expects a list of strings.
If the user making a request presents one of the tokens of an engine, they can
access information about the engine and make search requests.

Example configuration to restrict access to the Arch Linux Wiki engine:

.. code:: yaml

  - name: arch linux wiki
    engine: archlinux
    shortcut: al
    tokens: [ 'my-secret-token' ]

Unless a user has configured the right token, the engine is going to be hidden
from them.  It is not going to be included in the list of engines on the
Preferences page and in the output of `/config` REST API call.

Tokens can be added to one's configuration on the Preferences page under "Engine
tokens".  The input expects a comma separated list of strings.

The distribution of the tokens from the administrator to the users is not carved
in stone.  As providing access to such engines implies that the admin knows and
trusts the user, we do not see necessary to come up with a strict process.
Instead, we would like to add guidelines to the documentation of the feature.


Example: Multilingual Search
============================

SearXNG does not support true multilingual search.  You have to use the language
prefix in your search query when searching in a different language.

But there is a workaround: By adding a new search engine with a different
language, SearXNG will search in your default and other language.

Example configuration in settings.yml for a German and English speaker:

.. code-block:: yaml

    search:
        default_lang : "de"
        ...

    engines:
      - name : google english
        engine : google
        language : en
        ...

When searching, the default google engine will return German results and
"google english" will return English results.