1
0
mirror of https://github.com/searx/searx synced 2024-11-25 11:19:48 +01:00
searx/admin/no-sql-engines.html
2022-09-29 21:02:26 +00:00

265 lines
22 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Query SQL and NoSQL servers &#8212; Searx Documentation (Searx-1.1.0.tex)</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/searx.css" />
<link rel="stylesheet" type="text/css" href="../_static/tabs.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Plugins builtin" href="plugins.html" />
<link rel="prev" title="Search in indexers" href="indexer-engines.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="plugins.html" title="Plugins builtin"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="indexer-engines.html" title="Search in indexers"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Searx Documentation (Searx-1.1.0.tex)</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Administrator documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Query SQL and NoSQL servers</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="query-sql-and-nosql-servers">
<h1>Query SQL and NoSQL servers<a class="headerlink" href="#query-sql-and-nosql-servers" title="Permalink to this heading"></a></h1>
<section id="sql">
<h2>SQL<a class="headerlink" href="#sql" title="Permalink to this heading"></a></h2>
<p>SQL servers are traditional databases with predefined data schema. Furthermore,
modern versions also support BLOB data.</p>
<p>You can search in the following servers:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#postgresql">PostgreSQL</a></p></li>
<li><p><a class="reference internal" href="#mysql">MySQL</a></p></li>
<li><p><a class="reference internal" href="#sqlite">SQLite</a></p></li>
</ul>
<p>The configuration of the new database engines are similar. You must put a valid
SELECT SQL query in <code class="docutils literal notranslate"><span class="pre">query_str</span></code>. At the moment you can only bind at most
one parameter in your query.</p>
<p>Do not include LIMIT or OFFSET in your SQL query as the engines
rely on these keywords during paging.</p>
<section id="postgresql">
<h3>PostgreSQL<a class="headerlink" href="#postgresql" title="Permalink to this heading"></a></h3>
<p>Required PyPi package: <code class="docutils literal notranslate"><span class="pre">psychopg2</span></code></p>
<p>You can find an example configuration below:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><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">postgresql</span><span class="w"></span>
<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">postgresql</span><span class="w"></span>
<span class="w"> </span><span class="nt">database </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span><span class="w"></span>
<span class="w"> </span><span class="nt">username </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">searx</span><span class="w"></span>
<span class="w"> </span><span class="nt">password </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">password</span><span class="w"></span>
<span class="w"> </span><span class="nt">query_str </span><span class="p">:</span><span class="w"> </span><span class="s">&#39;SELECT</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">from</span><span class="nv"> </span><span class="s">my_table</span><span class="nv"> </span><span class="s">WHERE</span><span class="nv"> </span><span class="s">my_column</span><span class="nv"> </span><span class="s">=</span><span class="nv"> </span><span class="s">%(query)s&#39;</span><span class="w"></span>
<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">psql</span><span class="w"></span>
</pre></div>
</div>
<section id="available-options">
<h4>Available options<a class="headerlink" href="#available-options" title="Permalink to this heading"></a></h4>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">host</span></code>: IP address of the host running PostgreSQL. By default it is <code class="docutils literal notranslate"><span class="pre">127.0.0.1</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">port</span></code>: Port number PostgreSQL is listening on. By default it is <code class="docutils literal notranslate"><span class="pre">5432</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">database</span></code>: Name of the database you are connecting to.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">username</span></code>: Name of the user connecting to the database.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">password</span></code>: Password of the database user.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">query_str</span></code>: Query string to run. Keywords like <code class="docutils literal notranslate"><span class="pre">LIMIT</span></code> and <code class="docutils literal notranslate"><span class="pre">OFFSET</span></code> are not allowed. Required.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">limit</span></code>: Number of returned results per page. By default it is 10.</p></li>
</ul>
</section>
</section>
<section id="mysql">
<h3>MySQL<a class="headerlink" href="#mysql" title="Permalink to this heading"></a></h3>
<p>Required PyPi package: <code class="docutils literal notranslate"><span class="pre">mysql-connector-python</span></code></p>
<p>This is an example configuration for quering a MySQL server:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><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">mysql</span><span class="w"></span>
<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">mysql_server</span><span class="w"></span>
<span class="w"> </span><span class="nt">database </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span><span class="w"></span>
<span class="w"> </span><span class="nt">username </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">searx</span><span class="w"></span>
<span class="w"> </span><span class="nt">password </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">password</span><span class="w"></span>
<span class="w"> </span><span class="nt">limit </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">5</span><span class="w"></span>
<span class="w"> </span><span class="nt">query_str </span><span class="p">:</span><span class="w"> </span><span class="s">&#39;SELECT</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">from</span><span class="nv"> </span><span class="s">my_table</span><span class="nv"> </span><span class="s">WHERE</span><span class="nv"> </span><span class="s">my_column=%(query)s&#39;</span><span class="w"></span>
<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">mysql</span><span class="w"></span>
</pre></div>
</div>
<section id="id1">
<h4>Available options<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h4>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">host</span></code>: IP address of the host running MySQL. By default it is <code class="docutils literal notranslate"><span class="pre">127.0.0.1</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">port</span></code>: Port number MySQL is listening on. By default it is <code class="docutils literal notranslate"><span class="pre">3306</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">database</span></code>: Name of the database you are connecting to.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">auth_plugin</span></code>: Authentication plugin to use. By default it is <code class="docutils literal notranslate"><span class="pre">caching_sha2_password</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">username</span></code>: Name of the user connecting to the database.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">password</span></code>: Password of the database user.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">query_str</span></code>: Query string to run. Keywords like <code class="docutils literal notranslate"><span class="pre">LIMIT</span></code> and <code class="docutils literal notranslate"><span class="pre">OFFSET</span></code> are not allowed. Required.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">limit</span></code>: Number of returned results per page. By default it is 10.</p></li>
</ul>
</section>
</section>
<section id="sqlite">
<h3>SQLite<a class="headerlink" href="#sqlite" title="Permalink to this heading"></a></h3>
<p>You can read from your database <code class="docutils literal notranslate"><span class="pre">my_database</span></code> using this example configuration:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><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">sqlite</span><span class="w"></span>
<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">sqlite</span><span class="w"></span>
<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">sq</span><span class="w"></span>
<span class="w"> </span><span class="nt">database </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span><span class="w"></span>
<span class="w"> </span><span class="nt">query_str </span><span class="p">:</span><span class="w"> </span><span class="s">&#39;SELECT</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">FROM</span><span class="nv"> </span><span class="s">my_table</span><span class="nv"> </span><span class="s">WHERE</span><span class="nv"> </span><span class="s">my_column=:query&#39;</span><span class="w"></span>
</pre></div>
</div>
<section id="id2">
<h4>Available options<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h4>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">database</span></code>: Name of the database you are connecting to.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">query_str</span></code>: Query string to run. Keywords like <code class="docutils literal notranslate"><span class="pre">LIMIT</span></code> and <code class="docutils literal notranslate"><span class="pre">OFFSET</span></code> are not allowed. Required.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">limit</span></code>: Number of returned results per page. By default it is 10.</p></li>
</ul>
</section>
</section>
</section>
<section id="nosql">
<h2>NoSQL<a class="headerlink" href="#nosql" title="Permalink to this heading"></a></h2>
<p>NoSQL data stores are used for storing arbitrary data without first defining their
structure. To query the supported servers, you must install their drivers using PyPi.</p>
<p>You can search in the following servers:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#redis">Redis</a></p></li>
<li><p><a class="reference internal" href="#mongodb">MongoDB</a></p></li>
</ul>
<section id="redis">
<h3>Redis<a class="headerlink" href="#redis" title="Permalink to this heading"></a></h3>
<p>Reqired PyPi package: <code class="docutils literal notranslate"><span class="pre">redis</span></code></p>
<p>Example configuration:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><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">mystore</span><span class="w"></span>
<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><span class="w"></span>
<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">True</span><span class="w"></span>
<span class="w"> </span><span class="nt">host </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">127.0.0.1</span><span class="w"></span>
<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><span class="w"></span>
<span class="w"> </span><span class="nt">password </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">secret-password</span><span class="w"></span>
<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><span class="w"></span>
<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><span class="w"></span>
<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><span class="w"></span>
</pre></div>
</div>
<section id="id3">
<h4>Available options<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h4>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">host</span></code>: IP address of the host running Redis. By default it is <code class="docutils literal notranslate"><span class="pre">127.0.0.1</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">port</span></code>: Port number Redis is listening on. By default it is <code class="docutils literal notranslate"><span class="pre">6379</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">password</span></code>: Password if required by Redis.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">db</span></code>: Number of the database you are connecting to.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">exact_match_only</span></code>: Enable if you need exact matching. By default it is <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p></li>
</ul>
</section>
</section>
<section id="mongodb">
<h3>MongoDB<a class="headerlink" href="#mongodb" title="Permalink to this heading"></a></h3>
<p>Required PyPi package: <code class="docutils literal notranslate"><span class="pre">pymongo</span></code></p>
<p>Below is an example configuration for using a MongoDB collection:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><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><span class="w"></span>
<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><span class="w"></span>
<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">icm</span><span class="w"></span>
<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><span class="w"></span>
<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><span class="w"></span>
<span class="w"> </span><span class="nt">database </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">personal</span><span class="w"></span>
<span class="w"> </span><span class="nt">collection </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">income</span><span class="w"></span>
<span class="w"> </span><span class="nt">key </span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">month</span><span class="w"></span>
<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><span class="w"></span>
</pre></div>
</div>
<section id="id4">
<h4>Available options<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h4>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">host</span></code>: IP address of the host running MongoDB. By default it is <code class="docutils literal notranslate"><span class="pre">127.0.0.1</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">port</span></code>: Port number MongoDB is listening on. By default it is <code class="docutils literal notranslate"><span class="pre">27017</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">password</span></code>: Password if required by Redis.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">database</span></code>: Name of the database you are connecting to.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">collection</span></code>: Name of the collection you want to search in.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">exact_match_only</span></code>: Enable if you need exact matching. By default it is <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p></li>
</ul>
</section>
</section>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<span id="sidebar-top"></span>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/searx_logo_small.png" alt="Logo"/>
</a></p>
<h3>Project Links</h3>
<ul>
<li><a href="https://searx.github.io/searx/blog/index.html">Blog</a>
<li><a href="https://github.com/searx/searx">Source</a>
<li><a href="https://github.com/searx/searx/wiki">Wiki</a>
<li><a href="https://twitter.com/Searx_engine">Twitter</a>
<li><a href="https://github.com/searx/searx/issues">Issue Tracker</a>
</ul><h3>Navigation</h3>
<ul>
<li><a href="../index.html">Overview</a>
<ul>
<li><a href="index.html">Administrator documentation</a>
<ul>
<li>Previous: <a href="indexer-engines.html" title="previous chapter">Search in indexers</a>
<li>Next: <a href="plugins.html" title="next chapter">Plugins builtin</a></ul>
</li>
</ul>
</li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2015-2022, Adam Tauber, Noémi Ványi.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.1.1.
</div>
<script src="../_static/version_warning_offset.js"></script>
</body>
</html>