summaryrefslogtreecommitdiff
path: root/dev/engines/offline_concept.html
blob: 908e34dc22b25f5627c71259593add6709445b54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>

<html lang="en" data-content_root="../../">
  <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>Offline Concept &#8212; SearXNG Documentation (2024.5.10+ffb1001f8)</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=4f649999" />
    <link rel="stylesheet" type="text/css" href="../../_static/searxng.css?v=52e4ff28" />
    <link rel="stylesheet" type="text/css" href="../../_static/tabs.css?v=a5c4661c" />
    <script src="../../_static/documentation_options.js?v=ae3a6ae6"></script>
    <script src="../../_static/doctools.js?v=9a2dae69"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Demo Offline Engine" href="demo/demo_offline.html" />
    <link rel="prev" title="Z-Library" href="online/zlibrary.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="demo/demo_offline.html" title="Demo Offline Engine"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="online/zlibrary.html" title="Z-Library"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SearXNG Documentation (2024.5.10+ffb1001f8)</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >Developer documentation</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Engine Implementations</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Offline Concept</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="offline-concept">
<h1>Offline Concept<a class="headerlink" href="#offline-concept" title="Link to this heading"></a></h1>
<aside class="sidebar">
<p class="sidebar-title">offline engines</p>
<ul class="simple">
<li><p><a class="reference internal" href="demo/demo_offline.html#demo-offline-engine"><span class="std std-ref">Demo Offline Engine</span></a></p></li>
<li><p><a class="reference internal" href="offline/command-line-engines.html#engine-command"><span class="std std-ref">Command Line Engines</span></a></p></li>
<li><p><a class="reference internal" href="offline/sql-engines.html#sql-engines"><span class="std std-ref">SQL Engines</span></a></p></li>
<li><p><a class="reference internal" href="offline/nosql-engines.html#nosql-engines"><span class="std std-ref">NoSQL databases</span></a></p></li>
<li><p><a class="reference internal" href="../../src/searx.search.processors.html#module-searx.search.processors.offline" title="searx.search.processors.offline"><code class="xref py py-obj docutils literal notranslate"><span class="pre">searx.search.processors.offline</span></code></a></p></li>
</ul>
</aside>
<p>To extend the functionality of SearXNG, offline engines are going to be
introduced.  An offline engine is an engine which does not need Internet
connection to perform a search and does not use HTTP to communicate.</p>
<p>Offline engines can be configured, by adding those to the <cite>engines</cite> list of
<a class="reference external" href="https://github.com/searxng/searxng/blob/master/searx/settings.yml">settings.yml</a>.  An example skeleton for offline
engines can be found in <a class="reference internal" href="demo/demo_offline.html#demo-offline-engine"><span class="std std-ref">Demo Offline Engine</span></a> (<a class="reference external" href="https://github.com/searxng/searxng/blob/master/searx/engines/demo_offline.py">demo_offline.py</a>).</p>
<section id="programming-interface">
<h2>Programming Interface<a class="headerlink" href="#programming-interface" title="Link to this heading"></a></h2>
<dl>
<dt><a class="reference internal" href="demo/demo_offline.html#searx.engines.demo_offline.init" title="searx.engines.demo_offline.init"><code class="xref py py-func docutils literal notranslate"><span class="pre">init(engine_settings=None)</span></code></a></dt><dd><p>All offline engines can have their own init function to setup the engine before
accepting requests. The function gets the settings from settings.yml as a
parameter. This function can be omitted, if there is no need to setup anything
in advance.</p>
</dd>
<dt><code class="xref py py-func docutils literal notranslate"><span class="pre">search(query,</span> <span class="pre">params)</span></code></dt><dd><p>Each offline engine has a function named <code class="docutils literal notranslate"><span class="pre">search</span></code>.  This function is
responsible to perform a search and return the results in a presentable
format. (Where <em>presentable</em> means presentable by the selected result
template.)</p>
<p>The return value is a list of results retrieved by the engine.</p>
</dd>
<dt>Engine representation in <code class="docutils literal notranslate"><span class="pre">/config</span></code></dt><dd><p>If an engine is offline, the attribute <code class="docutils literal notranslate"><span class="pre">offline</span></code> is set to <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p>
</dd>
</dl>
</section>
<section id="extra-dependencies">
<span id="offline-requirements"></span><h2>Extra Dependencies<a class="headerlink" href="#extra-dependencies" title="Link to this heading"></a></h2>
<p>If an offline engine depends on an external tool, SearXNG does not install it by
default.  When an administrator configures such engine and starts the instance,
the process returns an error with the list of missing dependencies.  Also,
required dependencies will be added to the comment/description of the engine, so
admins can install packages in advance.</p>
<p>If there is a need to install additional packages in <em>Python’s Virtual
Environment</em> of your SearXNG instance you need 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>) first, for this you can use <a class="reference internal" href="../../utils/searxng.sh.html#searxng-sh"><span class="std std-ref">utils/searxng.sh</span></a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo utils/searxng.sh instance cmd bash
(searxng-pyenv)$ pip install ...
</pre></div>
</div>
</section>
<section id="private-engines-security">
<h2>Private engines (Security)<a class="headerlink" href="#private-engines-security" title="Link to this heading"></a></h2>
<p>To limit the access to offline engines, if an instance is available publicly,
administrators can set token(s) for each of the <a class="reference internal" href="../../admin/settings/settings_engine.html#private-engines"><span class="std std-ref">Private Engines (tokens)</span></a>.  If a
query contains a valid token, then SearXNG performs the requested private
search.  If not, requests from an offline engines return errors.</p>
</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/searxng-wordmark.svg" alt="Logo"/>
            </a></p>
  

<h3><a href="../../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../user/index.html">User information</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../own-instance.html">Why use a private instance?</a></li>
<li class="toctree-