nosql-engines.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ===============
  2. NoSQL databases
  3. ===============
  4. .. sidebar:: further read
  5. - `NoSQL databases <https://en.wikipedia.org/wiki/NoSQL>`_
  6. - `redis.io <https://redis.io/>`_
  7. - `MongoDB <https://www.mongodb.com>`_
  8. The following `NoSQL databases`_ are supported:
  9. - :ref:`engine redis_server`
  10. - :ref:`engine mongodb`
  11. All of the engines above are just commented out in the :origin:`settings.yml
  12. <searx/settings.yml>`, as you have to set various options and install
  13. dependencies before using them.
  14. By default, the engines use the ``key-value`` template for displaying results /
  15. see :origin:`oscar <searx/templates/oscar/result_templates/key-value.html>` &
  16. :origin:`simple <searx/templates/simple/result_templates/key-value.html>`
  17. themes. If you are not satisfied with the original result layout, you can use
  18. your own template, set ``result_template`` attribute to ``{template_name}`` and
  19. place the templates at::
  20. searx/templates/{theme_name}/result_templates/{template_name}
  21. Futhermore, if you do not wish to expose these engines on a public instance, you
  22. can still add them and limit the access by setting ``tokens`` as described in
  23. section :ref:`private engines`.
  24. Configure the engines
  25. =====================
  26. `NoSQL databases`_ are used for storing arbitrary data without first defining
  27. their structure.
  28. Extra Dependencies
  29. ------------------
  30. For using :ref:`engine redis_server` or :ref:`engine mongodb` you need to
  31. install additional packages in Python's Virtual Environment of your SearxNG
  32. instance. To switch into the environment (:ref:`searx-src`) you can use
  33. :ref:`searx.sh`::
  34. $ sudo utils/searx.sh shell
  35. (searx-pyenv)$ pip install ...
  36. .. _engine redis_server:
  37. Redis Server
  38. ------------
  39. .. _redis: https://github.com/andymccurdy/redis-py#installation
  40. .. sidebar:: info
  41. - ``pip install`` redis_
  42. - redis.io_
  43. - :origin:`redis_server.py <searx/engines/redis_server.py>`
  44. Redis is an open source (BSD licensed), in-memory data structure (key value
  45. based) store. Before configuring the ``redis_server`` engine, you must install
  46. the dependency redis_.
  47. Select a database to search in and set its index in the option ``db``. You can
  48. either look for exact matches or use partial keywords to find what you are
  49. looking for by configuring ``exact_match_only``. You find an example
  50. configuration below:
  51. .. code:: yaml
  52. # Required dependency: redis
  53. - name: myredis
  54. shortcut : rds
  55. engine: redis_server
  56. exact_match_only: false
  57. host: '127.0.0.1'
  58. port: 6379
  59. enable_http: true
  60. password: ''
  61. db: 0
  62. .. _engine mongodb:
  63. MongoDB
  64. -------
  65. .. _pymongo: https://github.com/mongodb/mongo-python-driver#installation
  66. .. sidebar:: info
  67. - ``pip install`` pymongo_
  68. - MongoDB_
  69. - :origin:`mongodb.py <searx/engines/mongodb.py>`
  70. MongoDB_ is a document based database program that handles JSON like data.
  71. Before configuring the ``mongodb`` engine, you must install the dependency
  72. redis_.
  73. In order to query MongoDB_, you have to select a ``database`` and a
  74. ``collection``. Furthermore, you have to select a ``key`` that is going to be
  75. searched. MongoDB_ also supports the option ``exact_match_only``, so configure
  76. it as you wish. Below is an example configuration for using a MongoDB
  77. collection:
  78. .. code:: yaml
  79. # MongoDB engine
  80. # Required dependency: pymongo
  81. - name: mymongo
  82. engine: mongodb
  83. shortcut: md
  84. exact_match_only: false
  85. host: '127.0.0.1'
  86. port: 27017
  87. enable_http: true
  88. results_per_page: 20
  89. database: 'business'
  90. collection: 'reviews' # name of the db collection
  91. key: 'name' # key in the collection to search for
  92. Acknowledgment
  93. ==============
  94. This development was sponsored by `Search and Discovery Fund
  95. <https://nlnet.nl/discovery>`_ of `NLnet Foundation <https://nlnet.nl/>`_.