engine_overview.rst 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. Engine overview
  2. ===============
  3. searx is a `metasearch-engine <https://en.wikipedia.org/wiki/Metasearch_engine>`__,
  4. so it is using different search engines to provide better results.
  5. Because there is no general search-api which can be used for every
  6. search-engine, there must be build an adapter between searx and the
  7. external search-engine. This adapters are stored in the folder
  8. `*searx/engines* <https://github.com/asciimoo/searx/tree/master/searx/engines>`__,
  9. and this site is build to make an general documentation about this
  10. engines
  11. .. contents::
  12. :depth: 3
  13. general engine configuration
  14. ----------------------------
  15. It is required to tell searx what results can the engine provide. The
  16. arguments can be inserted in the engine file, or in the settings file
  17. (normally ``settings.yml``). The arguments in the settings file override
  18. the one in the engine file.
  19. Really, it is for most options no difference if there are contained in
  20. the engine-file or in the settings. But there is a standard where to
  21. place specific arguments by default.
  22. engine-file
  23. ~~~~~~~~~~~
  24. +---------------------+-----------+-----------------------------------------+
  25. | argument | type | information |
  26. +=====================+===========+=========================================+
  27. | categories | list | pages, in which the engine is working |
  28. +---------------------+-----------+-----------------------------------------+
  29. | paging | boolean | support multible pages |
  30. +---------------------+-----------+-----------------------------------------+
  31. | language\_support | boolean | support language choosing |
  32. +---------------------+-----------+-----------------------------------------+
  33. settings.yml
  34. ~~~~~~~~~~~~
  35. +------------+----------+-----------------------------------------------+
  36. | argument | type | information |
  37. +============+==========+===============================================+
  38. | name | string | name of search-engine |
  39. +------------+----------+-----------------------------------------------+
  40. | engine | string | name of searx-engine (filename without .py) |
  41. +------------+----------+-----------------------------------------------+
  42. | shortcut | string | shortcut of search-engine |
  43. +------------+----------+-----------------------------------------------+
  44. | timeout | string | specific timeout for search-engine |
  45. +------------+----------+-----------------------------------------------+
  46. overrides
  47. ~~~~~~~~~
  48. There are some options, with have default values in the engine, but are
  49. often overwritten by the settings. If the option is assigned in the
  50. engine-file with ``None`` it has to be redefined in the settings,
  51. otherwise searx is not starting with that engine.
  52. The naming of that overrides can be wathever you want. But we recommend
  53. the using of already used overrides if possible:
  54. +-----------------------+----------+--------------------------------------------------------------+
  55. | argument | type | information |
  56. +=======================+==========+==============================================================+
  57. | base\_url | string | base-url, can be overwrite to use same engine on other url |
  58. +-----------------------+----------+--------------------------------------------------------------+
  59. | number\_of\_results | int | maximum number of results per request |
  60. +-----------------------+----------+--------------------------------------------------------------+
  61. | language | string | ISO code of language and country like en\_US |
  62. +-----------------------+----------+--------------------------------------------------------------+
  63. | api\_key | string | api-key if required by engine |
  64. +-----------------------+----------+--------------------------------------------------------------+
  65. example-code
  66. ~~~~~~~~~~~~
  67. .. code:: python
  68. # engine dependent config
  69. categories = ['general']
  70. paging = True
  71. language_support = True
  72. doing request
  73. -------------
  74. To perform a search you have to specific at least a url on which the
  75. request is performing
  76. passed arguments
  77. ~~~~~~~~~~~~~~~~
  78. This arguments can be used to calculate the search-query. Furthermore,
  79. some of that parameters are filled with default values which can be
  80. changed for special purpose.
  81. +----------------------+------------+------------------------------------------------------------------------+
  82. | argument | type | default-value, informations |
  83. +======================+============+========================================================================+
  84. | url | string | ``''`` |
  85. +----------------------+------------+------------------------------------------------------------------------+
  86. | method | string | ``'GET'`` |
  87. +----------------------+------------+------------------------------------------------------------------------+
  88. | headers | set | ``{}`` |
  89. +----------------------+------------+------------------------------------------------------------------------+
  90. | data | set | ``{}`` |
  91. +----------------------+------------+------------------------------------------------------------------------+
  92. | cookies | set | ``{}`` |
  93. +----------------------+------------+------------------------------------------------------------------------+
  94. | verify | boolean | ``True`` |
  95. +----------------------+------------+------------------------------------------------------------------------+
  96. | headers.User-Agent | string | a random User-Agent |
  97. +----------------------+------------+------------------------------------------------------------------------+
  98. | category | string | current category, like ``'general'`` |
  99. +----------------------+------------+------------------------------------------------------------------------+
  100. | started | datetime | current date-time |
  101. +----------------------+------------+------------------------------------------------------------------------+
  102. | pageno | int | current pagenumber |
  103. +----------------------+------------+------------------------------------------------------------------------+
  104. | language | string | specific language code like ``'en_US'``, or ``'all'`` if unspecified |
  105. +----------------------+------------+------------------------------------------------------------------------+
  106. parsed arguments
  107. ~~~~~~~~~~~~~~~~
  108. The function ``def request(query, params):`` is always returning the
  109. ``params`` variable back. Inside searx, the following paramters can be
  110. used to specific a search-request:
  111. +------------+-----------+----------------------------------------------------------+
  112. | argument | type | information |
  113. +============+===========+==========================================================+
  114. | url | string | requested url |
  115. +------------+-----------+----------------------------------------------------------+
  116. | method | string | HTTP request methode |
  117. +------------+-----------+----------------------------------------------------------+
  118. | headers | set | HTTP header informations |
  119. +------------+-----------+----------------------------------------------------------+
  120. | data | set | HTTP data informations (parsed if ``method != 'GET'``) |
  121. +------------+-----------+----------------------------------------------------------+
  122. | cookies | set | HTTP cookies |
  123. +------------+-----------+----------------------------------------------------------+
  124. | verify | boolean | Performing SSL-Validity check |
  125. +------------+-----------+----------------------------------------------------------+
  126. example-code
  127. ~~~~~~~~~~~~
  128. .. code:: python
  129. # search-url
  130. base_url = 'https://example.com/'
  131. search_string = 'search?{query}&page={page}'
  132. # do search-request
  133. def request(query, params):
  134. search_path = search_string.format(
  135. query=urlencode({'q': query}),
  136. page=params['pageno'])
  137. params['url'] = base_url + search_path
  138. return params
  139. returning results
  140. -----------------
  141. Searx has the possiblity to return results in different media-types.
  142. Currently the following media-types are supported:
  143. - default
  144. - images
  145. - videos
  146. - torrent
  147. - map
  148. to set another media-type as default, you must set the parameter
  149. ``template`` to the required type.
  150. default
  151. ~~~~~~~
  152. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  153. | result-parameter | information |
  154. +====================+====================================================================================================================================+
  155. | url | string, which is representing the url of the result |
  156. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  157. | title | string, which is representing the title of the result |
  158. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  159. | content | string, which is giving a general result-text |
  160. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  161. | publishedDate | `datetime.datetime <https://docs.python.org/2/library/datetime.html#datetime-objects>`__, represent when the result is published |
  162. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  163. images
  164. ~~~~~~
  165. to use this template, the parameter
  166. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  167. | result-parameter | information |
  168. +====================+===========================================================================================================================================================+
  169. | template | is set to ``images.html`` |
  170. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  171. | url | string, which is representing the url to the result site |
  172. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  173. | title | string, which is representing the title of the result *(partly implemented)* |
  174. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  175. | content | *(partly implemented)* |
  176. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  177. | publishedDate | `datetime.datetime <https://docs.python.org/2/library/datetime.html#datetime-objects>`__, represent when the result is published *(partly implemented)* |
  178. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  179. | img\_src | string, which is representing the url to the result image |
  180. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  181. | thumbnail\_src | string, which is representing the url to a small-preview image |
  182. +--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  183. videos
  184. ~~~~~~
  185. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  186. | result-parameter | information |
  187. +====================+====================================================================================================================================+
  188. | template | is set to ``videos.html`` |
  189. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  190. | url | string, which is representing the url of the result |
  191. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  192. | title | string, which is representing the title of the result |
  193. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  194. | content | *(not implemented yet)* |
  195. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  196. | publishedDate | `datetime.datetime <https://docs.python.org/2/library/datetime.html#datetime-objects>`__, represent when the result is published |
  197. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  198. | thumbnail | string, which is representing the url to a small-preview image |
  199. +--------------------+------------------------------------------------------------------------------------------------------------------------------------+
  200. torrent
  201. ~~~~~~~
  202. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  203. | result-parameter | information |
  204. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  205. | template | is set to ```torrent.html``` |
  206. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  207. | url | string, which is representing the url of the result |
  208. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  209. | title | string, which is representing the title of the result |
  210. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  211. | content | string, which is giving a general result-text |
  212. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  213. | publishedDate | [datetime.datetime](https://docs.python.org/2/library/datetime.html#datetime-objects), represent when the result is published _(not implemented yet)_ |
  214. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  215. | seed | int, number of seeder |
  216. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  217. | leech | int, number of leecher |
  218. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  219. | filesize | int, size of file in bytes |
  220. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  221. | files | int, number of files |
  222. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  223. | magnetlink | string, which is the [magnetlink](https://en.wikipedia.org/wiki/Magnet_URI_scheme) of the result |
  224. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  225. | torrentfile | string, which is the torrentfile of the result |
  226. +------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  227. map
  228. ~~~
  229. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  230. | result-parameter | information |
  231. +=========================+====================================================================================================================================+
  232. | url | string, which is representing the url of the result |
  233. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  234. | title | string, which is representing the title of the result |
  235. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  236. | content | string, which is giving a general result-text |
  237. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  238. | publishedDate | `datetime.datetime <https://docs.python.org/2/library/datetime.html#datetime-objects>`__, represent when the result is published |
  239. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  240. | latitude | latitude of result (in decimal format) |
  241. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  242. | longitude | longitude of result (in decimal format) |
  243. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  244. | boundingbox | boundingbox of result (array of 4. values ``[lat-min, lat-max, lon-min, lon-max]``) |
  245. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  246. | geojson | geojson of result (http://geojson.org) |
  247. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  248. | osm.type | type of osm-object (if OSM-Result) |
  249. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  250. | osm.id | id of osm-object (if OSM-Result) |
  251. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  252. | address.name | name of object |
  253. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  254. | address.road | street adress of object |
  255. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  256. | address.house\_number | house number of object |
  257. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  258. | address.locality | city, place of object |
  259. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  260. | address.postcode | postcode of object |
  261. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  262. | address.country | country of object |
  263. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------+