nosql-engines.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../../../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>NoSQL databases &#8212; SearXNG Documentation (2025.5.1+1a1628149)</title>
  8. <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=6625fa76" />
  9. <link rel="stylesheet" type="text/css" href="../../../_static/searxng.css?v=52e4ff28" />
  10. <script src="../../../_static/documentation_options.js?v=cc9fc81d"></script>
  11. <script src="../../../_static/doctools.js?v=9a2dae69"></script>
  12. <script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
  13. <script data-project="searxng" data-version="2025.5.1+1a1628149" src="../../../_static/describe_version.js?v=fa7f30d0"></script>
  14. <link rel="index" title="Index" href="../../../genindex.html" />
  15. <link rel="search" title="Search" href="../../../search.html" />
  16. <link rel="next" title="Local Search APIs" href="search-indexer-engines.html" />
  17. <link rel="prev" title="Command Line Engines" href="command-line-engines.html" />
  18. </head><body>
  19. <div class="related" role="navigation" aria-label="Related">
  20. <h3>Navigation</h3>
  21. <ul>
  22. <li class="right" style="margin-right: 10px">
  23. <a href="../../../genindex.html" title="General Index"
  24. accesskey="I">index</a></li>
  25. <li class="right" >
  26. <a href="../../../py-modindex.html" title="Python Module Index"
  27. >modules</a> |</li>
  28. <li class="right" >
  29. <a href="search-indexer-engines.html" title="Local Search APIs"
  30. accesskey="N">next</a> |</li>
  31. <li class="right" >
  32. <a href="command-line-engines.html" title="Command Line Engines"
  33. accesskey="P">previous</a> |</li>
  34. <li class="nav-item nav-item-0"><a href="../../../index.html">SearXNG Documentation (2025.5.1+1a1628149)</a> &#187;</li>
  35. <li class="nav-item nav-item-1"><a href="../../index.html" >Developer documentation</a> &#187;</li>
  36. <li class="nav-item nav-item-2"><a href="../index.html" accesskey="U">Engine Implementations</a> &#187;</li>
  37. <li class="nav-item nav-item-this"><a href="">NoSQL databases</a></li>
  38. </ul>
  39. </div>
  40. <div class="document">
  41. <div class="documentwrapper">
  42. <div class="bodywrapper">
  43. <div class="body" role="main">
  44. <section id="nosql-databases">
  45. <span id="nosql-engines"></span><h1>NoSQL databases<a class="headerlink" href="#nosql-databases" title="Link to this heading">¶</a></h1>
  46. <aside class="sidebar">
  47. <p class="sidebar-title">further read</p>
  48. <ul class="simple">
  49. <li><p><a class="reference external" href="https://en.wikipedia.org/wiki/NoSQL">NoSQL databases</a></p></li>
  50. <li><p><a class="reference external" href="https://redis.io/">redis.io</a></p></li>
  51. <li><p><a class="reference external" href="https://www.mongodb.com">MongoDB</a></p></li>
  52. </ul>
  53. </aside>
  54. <nav class="contents local" id="contents">
  55. <ul class="simple">
  56. <li><p><a class="reference internal" href="#extra-dependencies" id="id6">Extra Dependencies</a></p></li>
  57. <li><p><a class="reference internal" href="#configure-the-engines" id="id7">Configure the engines</a></p>
  58. <ul>
  59. <li><p><a class="reference internal" href="#redis-server" id="id8">Redis Server</a></p></li>
  60. <li><p><a class="reference internal" href="#engine-mongodb" id="id9">MongoDB</a></p></li>
  61. </ul>
  62. </li>
  63. </ul>
  64. </nav>
  65. <aside class="sidebar">
  66. <p class="sidebar-title">info</p>
  67. <p>Initial sponsored by <a class="reference external" href="https://nlnet.nl/discovery">Search and Discovery Fund</a> of <a class="reference external" href="https://nlnet.nl/">NLnet Foundation</a>.</p>
  68. </aside>
  69. <p>The following <a class="reference external" href="https://en.wikipedia.org/wiki/NoSQL">NoSQL databases</a> are supported:</p>
  70. <ul class="simple">
  71. <li><p><a class="reference internal" href="#engine-redis-server"><span class="std std-ref">Redis Server</span></a></p></li>
  72. <li><p><a class="reference internal" href="#engine-mongodb"><span class="std std-ref">MongoDB</span></a></p></li>
  73. </ul>
  74. <p>All of the engines above are just commented out in the <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/settings.yml">settings.yml</a>, as you have to set various options and install
  75. dependencies before using them.</p>
  76. <p>By default, the engines use the <code class="docutils literal notranslate"><span class="pre">key-value</span></code> template for displaying results /
  77. see <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/templates/simple/result_templates/key-value.html">simple</a>
  78. theme. If you are not satisfied with the original result layout, you can use
  79. your own template, set <code class="docutils literal notranslate"><span class="pre">result_template</span></code> attribute to <code class="docutils literal notranslate"><span class="pre">{template_name}</span></code> and
  80. place the templates at:</p>
  81. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">searx</span><span class="o">/</span><span class="n">templates</span><span class="o">/</span><span class="p">{</span><span class="n">theme_name</span><span class="p">}</span><span class="o">/</span><span class="n">result_templates</span><span class="o">/</span><span class="p">{</span><span class="n">template_name</span><span class="p">}</span>
  82. </pre></div>
  83. </div>
  84. <p>Furthermore, if you do not wish to expose these engines on a public instance, you
  85. can still add them and limit the access by setting <code class="docutils literal notranslate"><span class="pre">tokens</span></code> as described in
  86. section <a class="reference internal" href="../../../admin/settings/settings_engines.html#private-engines"><span class="std std-ref">Private Engines (tokens)</span></a>.</p>
  87. <section id="extra-dependencies">
  88. <h2><a class="toc-backref" href="#id6" role="doc-backlink">Extra Dependencies</a><a class="headerlink" href="#extra-dependencies" title="Link to this heading">¶</a></h2>
  89. <p>For using <a class="reference internal" href="#engine-redis-server"><span class="std std-ref">Redis Server</span></a> or <a class="reference internal" href="#engine-mongodb"><span class="std std-ref">MongoDB</span></a> you need to
  90. install additional packages in Python’s Virtual Environment of your SearXNG
  91. instance. To switch into the environment (<a class="reference internal" href="../../../admin/installation-searxng.html#searxng-src"><span class="std std-ref">Install SearXNG &amp; dependencies</span></a>) you can use
  92. <a class="reference internal" href="../../../utils/searxng.sh.html#searxng-sh"><span class="std std-ref">utils/searxng.sh</span></a>:</p>
  93. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo utils/searxng.sh instance cmd bash
  94. (searxng-pyenv)$ pip install ...
  95. </pre></div>
  96. </div>
  97. </section>
  98. <section id="configure-the-engines">
  99. <h2><a class="toc-backref" href="#id7" role="doc-backlink">Configure the engines</a><a class="headerlink" href="#configure-the-engines" title="Link to this heading">¶</a></h2>
  100. <p><a class="reference external" href="https://en.wikipedia.org/wiki/NoSQL">NoSQL databases</a> are used for storing arbitrary data without first defining
  101. their structure.</p>
  102. <section id="redis-server">
  103. <span id="engine-redis-server"></span><h3><a class="toc-backref" href="#id8" role="doc-backlink">Redis Server</a><a class="headerlink" href="#redis-server" title="Link to this heading">¶</a></h3>
  104. <aside class="sidebar">
  105. <p class="sidebar-title">info</p>
  106. <ul class="simple">
  107. <li><p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> <a class="reference external" href="https://github.com/andymccurdy/redis-py#installation">redis</a></p></li>
  108. <li><p><a class="reference external" href="https://redis.io/">redis.io</a></p></li>
  109. <li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/engines/redis_server.py">redis_server.py</a></p></li>
  110. </ul>
  111. </aside>
  112. <p id="module-searx.engines.redis_server">Redis is an open source (BSD licensed), in-memory data structure (key value
  113. based) store. Before configuring the <code class="docutils literal notranslate"><span class="pre">redis_server</span></code> engine, you must install
  114. the dependency <a class="reference external" href="https://github.com/andymccurdy/redis-py#installation">redis</a>.</p>
  115. <section id="configuration">
  116. <h4>Configuration<a class="headerlink" href="#configuration" title="Link to this heading">¶</a></h4>
  117. <p>Select a database to search in and set its index in the option <code class="docutils literal notranslate"><span class="pre">db</span></code>. You can
  118. either look for exact matches or use partial keywords to find what you are
  119. looking for by configuring <code class="docutils literal notranslate"><span class="pre">exact_match_only</span></code>.</p>
  120. </section>
  121. <section id="example">
  122. <h4>Example<a class="headerlink" href="#example" title="Link to this heading">¶</a></h4>
  123. <p>Below is an example configuration:</p>
  124. <div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="c1"># Required dependency: redis</span>
  125. <span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">myredis</span>
  126. <span class="w"> </span><span class="nt">shortcut </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">rds</span>
  127. <span class="w"> </span><span class="nt">engine</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">redis_server</span>
  128. <span class="w"> </span><span class="nt">exact_match_only</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">false</span>
  129. <span class="w"> </span><span class="nt">host</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;127.0.0.1&#39;</span>
  130. <span class="w"> </span><span class="nt">port</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">6379</span>
  131. <span class="w"> </span><span class="nt">enable_http</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
  132. <span class="w"> </span><span class="nt">password</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;&#39;</span>
  133. <span class="w"> </span><span class="nt">db</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">0</span>
  134. </pre></div>
  135. </div>
  136. </section>
  137. <section id="implementations">
  138. <h4>Implementations<a class="headerlink" href="#implementations" title="Link to this heading">¶</a></h4>
  139. </section>
  140. </section>
  141. <section id="engine-mongodb">
  142. <span id="id2"></span><h3><a class="toc-backref" href="#id9" role="doc-backlink">MongoDB</a><a class="headerlink" href="#engine-mongodb" title="Link to this heading">¶</a></h3>
  143. <aside class="sidebar">
  144. <p class="sidebar-title">info</p>
  145. <ul class="simple">
  146. <li><p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> <a class="reference external" href="https://github.com/mongodb/mongo-python-driver#installation">pymongo</a></p></li>
  147. <li><p><a class="reference external" href="https://www.mongodb.com">MongoDB</a></p></li>
  148. <li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/engines/mongodb.py">mongodb.py</a></p></li>
  149. </ul>
  150. </aside>
  151. <p id="module-searx.engines.mongodb"><a class="reference external" href="https://www.mongodb.com">MongoDB</a> is a document based database program that handles JSON like data.
  152. Before configuring the <code class="docutils literal notranslate"><span class="pre">mongodb</span></code> engine, you must install the dependency
  153. <a class="reference external" href="https://github.com/mongodb/mongo-python-driver#installation">pymongo</a>.</p>
  154. <section id="id3">
  155. <h4>Configuration<a class="headerlink" href="#id3" title="Link to this heading">¶</a></h4>
  156. <p>In order to query <a class="reference external" href="https://www.mongodb.com">MongoDB</a>, you have to select a <code class="docutils literal notranslate"><span class="pre">database</span></code> and a
  157. <code class="docutils literal notranslate"><span class="pre">collection</span></code>. Furthermore, you have to select a <code class="docutils literal notranslate"><span class="pre">key</span></code> that is going to be
  158. searched. <a class="reference external" href="https://www.mongodb.com">MongoDB</a> also supports the option <code class="docutils literal notranslate"><span class="pre">exact_match_only</span></code>, so configure
  159. it as you wish.</p>
  160. </section>
  161. <section id="id4">
  162. <h4>Example<a class="headerlink" href="#id4" title="Link to this heading">¶</a></h4>
  163. <p>Below is an example configuration for using a MongoDB collection:</p>
  164. <div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="c1"># MongoDB engine</span>
  165. <span class="c1"># Required dependency: pymongo</span>
  166. <span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">mymongo</span>
  167. <span class="w"> </span><span class="nt">engine</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">mongodb</span>
  168. <span class="w"> </span><span class="nt">shortcut</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">md</span>
  169. <span class="w"> </span><span class="nt">exact_match_only</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">false</span>
  170. <span class="w"> </span><span class="nt">host</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;127.0.0.1&#39;</span>
  171. <span class="w"> </span><span class="nt">port</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">27017</span>
  172. <span class="w"> </span><span class="nt">enable_http</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
  173. <span class="w"> </span><span class="nt">results_per_page</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">20</span>
  174. <span class="w"> </span><span class="nt">database</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;business&#39;</span>
  175. <span class="w"> </span><span class="nt">collection</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;reviews&#39;</span><span class="w"> </span><span class="c1"># name of the db collection</span>
  176. <span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;name&#39;</span><span class="w"> </span><span class="c1"># key in the collection to search for</span>
  177. </pre></div>
  178. </div>
  179. </section>
  180. <section id="id5">
  181. <h4>Implementations<a class="headerlink" href="#id5" title="Link to this heading">¶</a></h4>
  182. </section>
  183. </section>
  184. </section>
  185. </section>
  186. <div class="clearer"></div>
  187. </div>
  188. </div>
  189. </div>
  190. <span id="sidebar-top"></span>
  191. <div class="sphinxsidebar" role="navigation" aria-label="Main">
  192. <div class="sphinxsidebarwrapper">
  193. <p class="logo"><a href="../../../index.html">
  194. <img class="logo" src="../../../_static/searxng-wordmark.svg" alt="Logo of SearXNG"/>
  195. </a></p>
  196. <h3><a href="../../../index.html">Table of Contents</a></h3>
  197. <ul class="current">
  198. <li class="toctree-l1"><a class="reference internal" href="../../../user/index.html">User information</a></li>
  199. <li class="toctree-l1"><a class="reference internal" href="../../../own-instance.html">Why use a private instance?</a></li>
  200. <li class="toctree-l1"><a class="reference internal" href="../../../admin/index.html">Administrator documentation</a></li>
  201. <li class="toctree-l1 current"><a class="reference internal" href="../../index.html">Developer documentation</a><ul class="current">
  202. <li class="toctree-l2"><a class="reference internal" href="../../quickstart.html">Development Quickstart</a></li>
  203. <li class="toctree-l2"><a class="reference internal" href="../../rtm_asdf.html">Runtime Management</a></li>
  204. <li class="toctree-l2"><a class="reference internal" href="../../contribution_guide.html">How to contribute</a></li>
  205. <li class="toctree-l2"><a class="reference internal" href="../../extended_types.html">Extended Types</a></li>
  206. <li class="toctree-l2 current"><a class="reference internal" href="../index.html">Engine Implementations</a><ul class="current">
  207. <li class="toctree-l3"><a class="reference internal" href="../enginelib.html">Engine Library</a></li>
  208. <li class="toctree-l3"><a class="reference internal" href="../engines.html">SearXNG’s engines loader</a></li>
  209. <li class="toctree-l3"><a class="reference internal" href="../engine_overview.html">Engine Overview</a></li>
  210. <li class="toctree-l3"><a class="reference internal" href="../index.html#resultlist-and-engines">ResultList and engines</a></li>
  211. <li class="toctree-l3 current"><a class="reference internal" href="../index.html#engine-types">Engine Types</a><ul class="current">
  212. <li class="toctree-l4"><a class="reference internal" href="../index.html#online-engines">Online Engines</a></li>
  213. <li class="toctree-l4 current"><a class="reference internal" href="../index.html#offline-engines">Offline Engines</a><ul class="current">
  214. <li class="toctree-l5"><a class="reference internal" href="../offline_concept.html">Offline Concept</a></li>
  215. <li class="toctree-l5"><a class="reference internal" href="../demo/demo_offline.html">Demo Offline Engine</a></li>
  216. <li class="toctree-l5"><a class="reference internal" href="command-line-engines.html">Command Line Engines</a></li>
  217. <li class="toctree-l5 current"><a class="current reference internal" href="#">NoSQL databases</a></li>
  218. <li class="toctree-l5"><a class="reference internal" href="search-indexer-engines.html">Local Search APIs</a></li>
  219. <li class="toctree-l5"><a class="reference internal" href="sql-engines.html">SQL Engines</a></li>
  220. </ul>
  221. </li>
  222. <li class="toctree-l4"><a class="reference internal" href="../index.html#online-url-search">Online URL Search</a></li>
  223. <li class="toctree-l4"><a class="reference internal" href="../index.html#online-currency">Online Currency</a></li>
  224. <li class="toctree-l4"><a class="reference internal" href="../index.html#online-dictionary">Online Dictionary</a></li>
  225. </ul>
  226. </li>
  227. </ul>
  228. </li>
  229. <li class="toctree-l2"><a class="reference internal" href="../../result_types/index.html">Result Types</a></li>
  230. <li class="toctree-l2"><a class="reference internal" href="../../templates.html">Simple Theme Templates</a></li>
  231. <li class="toctree-l2"><a class="reference internal" href="../../search_api.html">Search API</a></li>
  232. <li class="toctree-l2"><a class="reference internal" href="../../plugins/index.html">Plugins</a></li>
  233. <li class="toctree-l2"><a class="reference internal" href="../../answerers/index.html">Answerers</a></li>
  234. <li class="toctree-l2"><a class="reference internal" href="../../translation.html">Translation</a></li>
  235. <li class="toctree-l2"><a class="reference internal" href="../../lxcdev.html">Developing in Linux Containers</a></li>
  236. <li class="toctree-l2"><a class="reference internal" href="../../makefile.html">Makefile &amp; <code class="docutils literal notranslate"><span class="pre">./manage</span></code></a></li>
  237. <li class="toctree-l2"><a class="reference internal" href="../../reST.html">reST primer</a></li>
  238. <li class="toctree-l2"><a class="reference internal" href="../../searxng_extra/index.html">Tooling box <code class="docutils literal notranslate"><span class="pre">searxng_extra</span></code></a></li>
  239. </ul>
  240. </li>
  241. <li class="toctree-l1"><a class="reference internal" href="../../../utils/index.html">DevOps tooling box</a></li>
  242. <li class="toctree-l1"><a class="reference internal" href="../../../src/index.html">Source-Code</a></li>
  243. </ul>
  244. <h3>Project Links</h3>
  245. <ul>
  246. <li><a href="https://github.com/searxng/searxng/tree/master">Source</a>
  247. <li><a href="https://github.com/searxng/searxng/wiki">Wiki</a>
  248. <li><a href="https://searx.space">Public instances</a>
  249. <li><a href="https://github.com/searxng/searxng/issues">Issue Tracker</a>
  250. </ul><h3>Navigation</h3>
  251. <ul>
  252. <li><a href="../../../index.html">Overview</a>
  253. <ul>
  254. <li><a href="../../index.html">Developer documentation</a>
  255. <ul>
  256. <li><a href="../index.html">Engine Implementations</a>
  257. <ul>
  258. <li>Previous: <a href="command-line-engines.html" title="previous chapter">Command Line Engines</a>
  259. <li>Next: <a href="search-indexer-engines.html" title="next chapter">Local Search APIs</a></ul>
  260. </li></ul>
  261. </li>
  262. </ul>
  263. </li>
  264. </ul>
  265. <search id="searchbox" style="display: none" role="search">
  266. <h3 id="searchlabel">Quick search</h3>
  267. <div class="searchformwrapper">
  268. <form class="search" action="../../../search.html" method="get">
  269. <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
  270. <input type="submit" value="Go" />
  271. </form>
  272. </div>
  273. </search>
  274. <script>document.getElementById('searchbox').style.display = "block"</script>
  275. <div role="note" aria-label="source link">
  276. <h3>This Page</h3>
  277. <ul class="this-page-menu">
  278. <li><a href="../../../_sources/dev/engines/offline/nosql-engines.rst.txt"
  279. rel="nofollow">Show Source</a></li>
  280. </ul>
  281. </div>
  282. </div>
  283. </div>
  284. <div class="clearer"></div>
  285. </div>
  286. <div class="footer" role="contentinfo">
  287. &#169; Copyright SearXNG team.
  288. </div>
  289. </body>
  290. </html>