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

Functions

 init (engine_settings=None)
 
EngineResults 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 35 of file demo_offline.py.

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

◆ search()

EngineResults 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 52 of file demo_offline.py.

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

Variable Documentation

◆ _my_offline_engine

searx.engines.demo_offline._my_offline_engine = None
protected

Definition at line 32 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 23 of file demo_offline.py.

◆ categories

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

Definition at line 19 of file demo_offline.py.

◆ disabled

bool searx.engines.demo_offline.disabled = True

Definition at line 20 of file demo_offline.py.

◆ engine_type

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

Definition at line 18 of file demo_offline.py.

◆ timeout

float searx.engines.demo_offline.timeout = 2.0

Definition at line 21 of file demo_offline.py.