intro-offline.rst 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ===============================
  2. Preparation for offline engines
  3. ===============================
  4. Offline engines
  5. ===============
  6. To extend the functionality of searx, offline engines are going to be
  7. introduced. An offline engine is an engine which does not need Internet
  8. connection to perform a search and does not use HTTP to communicate.
  9. Offline engines can be configured as online engines, by adding those to the
  10. `engines` list of :origin:`settings.yml <searx/settings.yml>`. Thus, searx
  11. finds the engine file and imports it.
  12. Example skeleton for the new engines:
  13. .. code:: python
  14. from subprocess import PIPE, Popen
  15. categories = ['general']
  16. offline = True
  17. def init(settings):
  18. pass
  19. def search(query, params):
  20. process = Popen(['ls', query], stdout=PIPE)
  21. return_code = process.wait()
  22. if return_code != 0:
  23. raise RuntimeError('non-zero return code', return_code)
  24. results = []
  25. line = process.stdout.readline()
  26. while line:
  27. result = parse_line(line)
  28. results.append(results)
  29. line = process.stdout.readline()
  30. return results
  31. Development progress
  32. ====================
  33. First, a proposal has been created as a Github issue. Then it was moved to the
  34. wiki as a design document. You can read it here: :wiki:`Offline-engines`.
  35. In this development step, searx core was prepared to accept and perform offline
  36. searches. Offline search requests are scheduled together with regular offline
  37. requests.
  38. As offline searches can return arbitrary results depending on the engine, the
  39. current result templates were insufficient to present such results. Thus, a new
  40. template is introduced which is caplable of presenting arbitrary key value pairs
  41. as a table. You can check out the pull request for more details see
  42. :pull:`1700`.
  43. Next steps
  44. ==========
  45. Today, it is possible to create/run an offline engine. However, it is going to be publicly available for everyone who knows the searx instance. So the next step is to introduce token based access for engines. This way administrators are able to limit the access to private engines.
  46. Acknowledgement
  47. ===============
  48. This development was sponsored by `Search and Discovery Fund`_ of `NLnet Foundation`_ .
  49. .. _Search and Discovery Fund: https://nlnet.nl/discovery
  50. .. _NLnet Foundation: https://nlnet.nl/
  51. | Happy hacking.
  52. | kvch // 2019.10.21 17:03