@@ -1,21 +1,25 @@
1+
2+.. _engines-dev:
3+
4+===============
15Engine overview
26===============
37
8+.. _metasearch-engine: https://en.wikipedia.org/wiki/Metasearch_engine
49
5−searx is a `metasearch-engine <https://en.wikipedia.org/wiki/Metasearch_engine>`__,
6−so it uses different search engines to provide better results.
7−
8−Because there is no general search API which could be used for every
9−search engine, an adapter has to be built between searx and the
10−external search engines. Adapters are stored under the folder
11−:origin:`searx/engines`.
10+searx is a metasearch-engine_, so it uses different search engines to provide
11+better results.
1212
13+Because there is no general search API which could be used for every search
14+engine, an adapter has to be built between searx and the external search
15+engines. Adapters are stored under the folder :origin:`searx/engines`.
1316
1417.. contents::
1518 :depth: 3
19+ :backlinks: entry
1620
1721general engine configuration
18−----------------------------
22+============================
1923
2024It is required to tell searx the type of results the engine provides. The
2125arguments can be set in the engine file or in the settings file
@@ -23,292 +27,239 @@ arguments can be set in the engine file or in the settings file
2327the ones in the engine file.
2428
2529It does not matter if an option is stored in the engine file or in the
26−settings. However, the standard way is the following:
30+settings. However, the standard way is the following:
2731
2832
2933engine file
30−~~~~~~~~~~~
31−
32−+----------------------+-----------+-----------------------------------------+
33−| argument | type | information |
34−+======================+===========+=========================================+
35−| categories | list | pages, in which the engine is working |
36−+----------------------+-----------+-----------------------------------------+
37−| paging | boolean | support multible pages |
38−+----------------------+-----------+-----------------------------------------+
39−| language\_support | boolean | support language choosing |
40−+----------------------+-----------+-----------------------------------------+
41−| time\_range\_support | boolean | support search time range |
42−+----------------------+-----------+-----------------------------------------+
43−| offline | boolean | engine runs offline |
44−+----------------------+-----------+-----------------------------------------+
34+-----------
35+
36+======================= =========== ===========================================
37+argument type information
38+======================= =========== ===========================================
39+categories list pages, in which the engine is working
40+paging boolean support multible pages
41+language_support boolean support language choosing
42+time_range_support boolean support search time range
43+offline boolean engine runs offline
44+======================= =========== ===========================================
45+
4546
4647settings.yml
47−~~~~~~~~~~~~
48−
49−+------------+----------+-----------------------------------------------+
50−| argument | type | information |
51−+============+==========+===============================================+
52−| name | string | name of search-engine |
53−+------------+----------+-----------------------------------------------+
54−| engine | string | name of searx-engine (filename without .py) |
55−+------------+----------+-----------------------------------------------+
56−| shortcut | string | shortcut of search-engine |
57−+------------+----------+-----------------------------------------------+
58−| timeout | string | specific timeout for search-engine |
59−+------------+----------+-----------------------------------------------+
48+------------
49+
50+======================= =========== ===========================================
51+argument type information
52+======================= =========== ===========================================
53+name string name of search-engine
54+engine string name of searx-engine
55+ (filename without ``.py``)
56+shortcut string shortcut of search-engine
57+timeout string specific timeout for search-engine
58+======================= =========== ===========================================
59+
6060
6161overrides
62−~~~~~~~~~
63−
64−A few of the options have default values in the engine, but are
65−often overwritten by the settings. If ``None`` is assigned to an option
66−in the engine file, it has to be redefined in the settings,
67−otherwise searx will not start with that engine.
68−
69−The naming of overrides is arbitrary. But the recommended
70−overrides are the following:
71−
72−+-----------------------+----------+----------------------------------------------------------------+
73−| argument | type | information |
74−+=======================+==========+================================================================+
75−| base\_url | string | base-url, can be overwritten to use same engine on other URL |
76−+-----------------------+----------+----------------------------------------------------------------+
77−| number\_of\_results | int | maximum number of results per request |
78−+-----------------------+----------+----------------------------------------------------------------+
79−| language | string | ISO code of language and country like en\_US |
80−+-----------------------+----------+----------------------------------------------------------------+
81−| api\_key | string | api-key if required by engine |
82−+-----------------------+----------+----------------------------------------------------------------+
62+---------
63+
64+A few of the options have default values in the engine, but are often
65+overwritten by the settings. If ``None`` is assigned to an option in the engine
66+file, it has to be redefined in the settings, otherwise searx will not start
67+with that engine.
68+
69+The naming of overrides is arbitrary. But the recommended overrides are the
70+following:
71+
72+======================= =========== ===========================================
73+argument type information
74+======================= =========== ===========================================
75+base_url string base-url, can be overwritten to use same
76+ engine on other URL
77+number_of_results int maximum number of results per request
78+language string ISO code of language and country like en_US
79+api_key string api-key if required by engine
80+======================= =========== ===========================================
8381
8482example code
85−~~~~~~~~~~~~
83+------------
8684
8785.. code:: python
8886
89− # engine dependent config
90− categories = ['general']
91− paging = True
92− language_support = True
87+ # engine dependent config
88+ categories = ['general']
89+ paging = True
90+ language_support = True
91+
9392
9493making a request
95−----------------
94+================
9695
97−To perform a search an URL have to be specified. In addition to
98−specifying an URL, arguments can be passed to the query.
96+To perform a search an URL have to be specified. In addition to specifying an
97+URL, arguments can be passed to the query.
9998
10099passed arguments
101−~~~~~~~~~~~~~~~~
100+----------------
102101
103−These arguments can be used to construct the search query. Furthermore,
102+These arguments can be used to construct the search query. Furthermore,
104103parameters with default value can be redefined for special purposes.
105104
106−+----------------------+------------+------------------------------------------------------------------------+
107−| argument | type | default-value, information |
108−+======================+============+========================================================================+
109−| url | string | ``''`` |
110−+----------------------+------------+------------------------------------------------------------------------+
111−| method | string | ``'GET'`` |
112−+----------------------+------------+------------------------------------------------------------------------+
113−| headers | set | ``{}`` |
114−+----------------------+------------+------------------------------------------------------------------------+
115−| data | set | ``{}`` |
116−+----------------------+------------+------------------------------------------------------------------------+
117−| cookies | set | ``{}`` |
118−+----------------------+------------+------------------------------------------------------------------------+
119−| verify | boolean | ``True`` |
120−+----------------------+------------+------------------------------------------------------------------------+
121−| headers.User-Agent | string | a random User-Agent |
122−+----------------------+------------+------------------------------------------------------------------------+
123−| category | string | current category, like ``'general'`` |
124−+----------------------+------------+------------------------------------------------------------------------+
125−| started | datetime | current date-time |
126−+----------------------+------------+------------------------------------------------------------------------+
127−| pageno | int | current pagenumber |
128−+----------------------+------------+------------------------------------------------------------------------+
129−| language | string | specific language code like ``'en_US'``, or ``'all'`` if unspecified |
130−+----------------------+------------+------------------------------------------------------------------------+
105+====================== ============ ========================================================================
106+argument type default-value, information
107+====================== ============ ========================================================================
108+url string ``''``
109+method string ``'GET'``
110+headers set ``{}``
111+data set ``{}``
112+cookies set ``{}``
113+verify boolean ``True``
114+headers.User-Agent string a random User-Agent
115+category string current category, like ``'general'``
116+started datetime current date-time
117+pageno int current pagenumber
118+language string specific language code like ``'en_US'``, or ``'all'`` if unspecified
119+====================== ============ ========================================================================
131120
132121parsed arguments
133−~~~~~~~~~~~~~~~~
134−
135−The function ``def request(query, params):`` always returns the
136−``params`` variable. Inside searx, the following paramters can be
137−used to specify a search request:
138−
139−+------------+-----------+---------------------------------------------------------+
140−| argument | type | information |
141−+============+===========+=========================================================+
142−| url | string | requested url |
143−+------------+-----------+---------------------------------------------------------+
144−| method | string | HTTP request method |
145−+------------+-----------+---------------------------------------------------------+
146−| headers | set | HTTP header information |
147−+------------+-----------+---------------------------------------------------------+
148−| data | set | HTTP data information (parsed if ``method != 'GET'``) |
149−+------------+-----------+---------------------------------------------------------+
150−| cookies | set | HTTP cookies |
151−+------------+-----------+---------------------------------------------------------+
152−| verify | boolean | Performing SSL-Validity check |
153−+------------+-----------+---------------------------------------------------------+
122+----------------
123+
124+The function ``def request(query, params):`` always returns the ``params``
125+variable. Inside searx, the following paramters can be used to specify a search
126+request:
127+
128+============ =========== =========================================================
129+argument type information
130+============ =========== =========================================================
131+url string requested url
132+method string HTTP request method
133+headers set HTTP header information
134+data set HTTP data information (parsed if ``method != 'GET'``)
135+cookies set HTTP cookies
136+verify boolean Performing SSL-Validity check
137+============ =========== =========================================================
138+
154139
155140example code
156−~~~~~~~~~~~~
141+------------
157142
158143.. code:: python
159144
160− # search-url
161− base_url = 'https://example.com/'
162− search_string = 'search?{query}&page={page}'
145+ # search-url
146+ base_url = 'https://example.com/'
147+ search_string = 'search?{query}&page={page}'
163148
164− # do search-request
165− def request(query, params):
166− search_path = search_string.format(
167− query=urlencode({'q': query}),
168− page=params['pageno'])
149+ # do search-request
150+ def request(query, params):
151+ search_path = search_string.format(
152+ query=urlencode({'q': query}),
153+ page=params['pageno'])
169154
170− params['url'] = base_url + search_path
155+ params['url'] = base_url + search_path
156+
157+ return params
171158
172− return params
173159
174160returned results
175−----------------
161+================
176162
177−Searx is able to return results of different media-types.
178−Currently the following media-types are supported:
163+Searx is able to return results of different media-types. Currently the
164+following media-types are supported:
179165
180−- default
181−- images
182−- videos
183−- torrent
184−- map
166+- default_
167+- images_
168+- videos_
169+- torrent_
170+- map_
185171
186−To set another media-type as default, the parameter
187−``template`` must be set to the desired type.
172+To set another media-type as default, the parameter ``template`` must be set to
173+the desired type.
188174
189175default
190−~~~~~~~
191−
192−+--------------------+---------------------------------------------------------------------------------------------------------------+
193−| result-parameter | information |
194−+====================+===============================================================================================================+
195−| url | string, url of the result |
196−+--------------------+---------------------------------------------------------------------------------------------------------------+
197−| title | string, title of the result |
198−+--------------------+---------------------------------------------------------------------------------------------------------------+
199−| content | string, general result-text |
200−+--------------------+---------------------------------------------------------------------------------------------------------------+
201−| publishedDate | :py:class:`datetime.datetime`, time of publish |
202−+--------------------+---------------------------------------------------------------------------------------------------------------+
176+-------
177+
178+========================= =====================================================
179+result-parameter information
180+========================= =====================================================
181+url string, url of the result
182+title string, title of the result
183+content string, general result-text
184+publishedDate :py:class:`datetime.datetime`, time of publish
185+========================= =====================================================
203186
204187images
205−~~~~~~
206−
207−to use this template, the parameter
208−
209−+--------------------+---------------------------------------------------------------------------------------------------------------------------------------+
210−| result-parameter | information |
211−+====================+=======================================================================================================================================+
212−| template | is set to ``images.html`` |
213−+--------------------+---------------------------------------------------------------------------------------------------------------------------------------+
214−| url | string, url to the result site |
215−+--------------------+---------------------------------------------------------------------------------------------------------------------------------------+
216−| title | string, title of the result *(partly implemented)* |
217−+--------------------+---------------------------------------------------------------------------------------------------------------------------------------+
218−| content | *(partly implemented)* |
219−+--------------------+---------------------------------------------------------------------------------------------------------------------------------------+
220−| publishedDate | :py:class:`datetime.datetime`, time of publish *(partly implemented)* |
221−+--------------------+---------------------------------------------------------------------------------------------------------------------------------------+
222−| img\_src | string, url to the result image |
223−+--------------------+---------------------------------------------------------------------------------------------------------------------------------------+
224−| thumbnail\_src | string, url to a small-preview image |
225−+--------------------+---------------------------------------------------------------------------------------------------------------------------------------+
188+------
189+
190+To use this template, the parameter:
191+
192+========================= =====================================================
193+result-parameter information
194+========================= =====================================================
195+template is set to ``images.html``
196+url string, url to the result site
197+title string, title of the result *(partly implemented)*
198+content *(partly implemented)*
199+publishedDate :py:class:`datetime.datetime`,
200+ time of publish *(partly implemented)*
201+img\_src string, url to the result image
202+thumbnail\_src string, url to a small-preview image
203+========================= =====================================================
226204
227205videos
228−~~~~~~
229−
230−+--------------------+--------------------------------------------------------------------------------------------------------------+
231−| result-parameter | information |
232−+====================+==============================================================================================================+
233−| template | is set to ``videos.html`` |
234−+--------------------+--------------------------------------------------------------------------------------------------------------+
235−| url | string, url of the result |
236−+--------------------+--------------------------------------------------------------------------------------------------------------+
237−| title | string, title of the result |
238−+--------------------+--------------------------------------------------------------------------------------------------------------+
239−| content | *(not implemented yet)* |
240−+--------------------+--------------------------------------------------------------------------------------------------------------+
241−| publishedDate | :py:class:`datetime.datetime`, time of publish |
242−+--------------------+--------------------------------------------------------------------------------------------------------------+
243−| thumbnail | string, url to a small-preview image |
244−+--------------------+--------------------------------------------------------------------------------------------------------------+
206+------
207+
208+========================= =====================================================
209+result-parameter information
210+========================= =====================================================
211+template is set to ``videos.html``
212+url string, url of the result
213+title string, title of the result
214+content *(not implemented yet)*
215+publishedDate :py:class:`datetime.datetime`, time of publish
216+thumbnail string, url to a small-preview image
217+========================= =====================================================
245218
246219torrent
247−~~~~~~~
248−
249−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
250−| result-parameter | information |
251−+==================+=======================================================================================================================================+
252−| template | is set to ``torrent.html`` |
253−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
254−| url | string, url of the result |
255−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
256−| title | string, title of the result |
257−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
258−| content | string, general result-text |
259−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
260−| publishedDate | :py:class:`datetime.datetime`, time of publish *(not implemented yet)* |
261−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
262−| seed | int, number of seeder |
263−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
264−| leech | int, number of leecher |
265−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
266−| filesize | int, size of file in bytes |
267−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
268−| files | int, number of files |
269−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
270−| magnetlink | string, `magnetlink <https://en.wikipedia.org/wiki/Magnet_URI_scheme>`__ of the result |
271−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
272−| torrentfile | string, torrentfile of the result |
273−+------------------+---------------------------------------------------------------------------------------------------------------------------------------+
220+-------
221+
222+.. _magnetlink: https://en.wikipedia.org/wiki/Magnet_URI_scheme
223+
224+========================= =====================================================
225+result-parameter information
226+========================= =====================================================
227+template is set to ``torrent.html``
228+url string, url of the result
229+title string, title of the result
230+content string, general result-text
231+publishedDate :py:class:`datetime.datetime`,
232+ time of publish *(not implemented yet)*
233+seed int, number of seeder
234+leech int, number of leecher
235+filesize int, size of file in bytes
236+files int, number of files
237+magnetlink string, magnetlink_ of the result
238+torrentfile string, torrentfile of the result
239+========================= =====================================================
274240
275241
276242map
277−~~~
278−
279−+-------------------------+--------------------------------------------------------------------------------------------------------------+
280−| result-parameter | information |
281−+=========================+==============================================================================================================+
282−| url | string, url of the result |
283−+-------------------------+--------------------------------------------------------------------------------------------------------------+
284−| title | string, title of the result |
285−+-------------------------+--------------------------------------------------------------------------------------------------------------+
286−| content | string, general result-text |
287−+-------------------------+--------------------------------------------------------------------------------------------------------------+
288−| publishedDate | :py:class:`datetime.datetime`, time of publish |
289−+-------------------------+--------------------------------------------------------------------------------------------------------------+
290−| latitude | latitude of result (in decimal format) |
291−+-------------------------+--------------------------------------------------------------------------------------------------------------+
292−| longitude | longitude of result (in decimal format) |
293−+-------------------------+--------------------------------------------------------------------------------------------------------------+
294−| boundingbox | boundingbox of result (array of 4. values ``[lat-min, lat-max, lon-min, lon-max]``) |
295−+-------------------------+--------------------------------------------------------------------------------------------------------------+
296−| geojson | geojson of result (http://geojson.org) |
297−+-------------------------+--------------------------------------------------------------------------------------------------------------+
298−| osm.type | type of osm-object (if OSM-Result) |
299−+-------------------------+--------------------------------------------------------------------------------------------------------------+
300−| osm.id | id of osm-object (if OSM-Result) |
301−+-------------------------+--------------------------------------------------------------------------------------------------------------+
302−| address.name | name of object |
303−+-------------------------+--------------------------------------------------------------------------------------------------------------+
304−| address.road | street name of object |
305−+-------------------------+--------------------------------------------------------------------------------------------------------------+
306−| address.house\_number | house number of object |
307−+-------------------------+--------------------------------------------------------------------------------------------------------------+
308−| address.locality | city, place of object |
309−+-------------------------+--------------------------------------------------------------------------------------------------------------+
310−| address.postcode | postcode of object |
311−+-------------------------+--------------------------------------------------------------------------------------------------------------+
312−| address.country | country of object |
313−+-------------------------+--------------------------------------------------------------------------------------------------------------+
314−
243+---
244+
245+========================= =====================================================
246+result-parameter information
247+========================= =====================================================
248+url string, url of the result
249+title string, title of the result
250+content string, general result-text
251+publishedDate :py:class:`datetime.datetime`, time of publish
252+latitude latitude of result (in decimal format)
253+longitude longitude of result (in decimal format)
254+boundingbox boundingbox of result (array of 4. values
255+ ``[lat-min, lat-max, lon-min, lon-max]``)
256+geojson geojson of result (http://geojson.org)
257+osm.type type of osm-object (if OSM-Result)
258+osm.id id of osm-object (if OSM-Result)
259+address.name name of object
260+address.road street name of object
261+address.house_number house number of object
262+address.locality city, place of object
263+address.postcode postcode of object
264+address.country country of object
265+========================= =====================================================