.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.demo_offline Namespace Reference

Functions

 init (engine_settings=None)
 
 search (query, request_params)
 

Variables

str engine_type = 'offline'
 
list categories = ['general']
 
bool disabled = True
 
float timeout = 2.0
 
dict about
 
 _my_offline_engine = None
 

Detailed Description

Within this module we implement a *demo offline engine*.  Do not look to
close to the implementation, its just a simple example.  To get in use of this
*demo* engine add the following entry to your engines list in ``settings.yml``:

.. code:: yaml

  - name: my offline engine
    engine: demo_offline
    shortcut: demo
    disabled: false

Function Documentation

◆ init()

searx.engines.demo_offline.init ( engine_settings = None)
Initialization of the (offline) engine.  The origin of this demo engine is a
simple json string which is loaded in this example while the engine is
initialized.

Definition at line 34 of file demo_offline.py.

34def init(engine_settings=None):
35 """Initialization of the (offline) engine. The origin of this demo engine is a
36 simple json string which is loaded in this example while the engine is
37 initialized.
38
39 """
40 global _my_offline_engine # pylint: disable=global-statement
41
42 _my_offline_engine = (
43 '[ {"value": "%s"}'
44 ', {"value":"first item"}'
45 ', {"value":"second item"}'
46 ', {"value":"third item"}'
47 ']' % engine_settings.get('name')
48 )
49
50

◆ search()

searx.engines.demo_offline.search ( query,
request_params )
Query (offline) engine and return results.  Assemble the list of results from
your local engine.  In this demo engine we ignore the 'query' term, usual
you would pass the 'query' term to your local engine to filter out the
results.

Definition at line 51 of file demo_offline.py.

51def search(query, request_params):
52 """Query (offline) engine and return results. Assemble the list of results from
53 your local engine. In this demo engine we ignore the 'query' term, usual
54 you would pass the 'query' term to your local engine to filter out the
55 results.
56
57 """
58 ret_val = []
59
60 result_list = json.loads(_my_offline_engine)
61
62 for row in result_list:
63 entry = {
64 'query': query,
65 'language': request_params['searxng_locale'],
66 'value': row.get("value"),
67 # choose a result template or comment out to use the *default*
68 'template': 'key-value.html',
69 }
70 ret_val.append(entry)
71
72 return ret_val

Variable Documentation

◆ _my_offline_engine

searx.engines.demo_offline._my_offline_engine = None
protected

Definition at line 31 of file demo_offline.py.

◆ about

dict searx.engines.demo_offline.about
Initial value:
1= {
2 "wikidata_id": None,
3 "official_api_documentation": None,
4 "use_official_api": False,
5 "require_api_key": False,
6 "results": 'JSON',
7}

Definition at line 22 of file demo_offline.py.

◆ categories

list searx.engines.demo_offline.categories = ['general']

Definition at line 18 of file demo_offline.py.

◆ disabled

bool searx.engines.demo_offline.disabled = True

Definition at line 19 of file demo_offline.py.

◆ engine_type

str searx.engines.demo_offline.engine_type = 'offline'

Definition at line 17 of file demo_offline.py.

◆ timeout

float searx.engines.demo_offline.timeout = 2.0

Definition at line 20 of file demo_offline.py.