nosql-engines.rst 3.7 KB

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