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

Functions

 get_time_range (time_range)
 
 request (query, params)
 
 response (resp)
 

Variables

dict about
 
bool paging = True
 
bool time_range_support = True
 
 base_url = None
 
str search_dir = ''
 
 mount_prefix = None
 
 dl_prefix = None
 
str embedded_url = '<{ttype} controls height="166px" ' + 'src="{url}" type="{mtype}"></{ttype}>'
 

Detailed Description

.. sidebar:: info

   - `Recoll <https://www.lesbonscomptes.com/recoll/>`_
   - `recoll-webui <https://framagit.org/medoc92/recollwebui.git>`_
   - :origin:`searx/engines/recoll.py`

Recoll_ is a desktop full-text search tool based on Xapian.  By itself Recoll_
does not offer WEB or API access, this can be achieved using recoll-webui_

Configuration
=============

You must configure the following settings:

``base_url``:
  Location where recoll-webui can be reached.

``mount_prefix``:
  Location where the file hierarchy is mounted on your *local* filesystem.

``dl_prefix``:
  Location where the file hierarchy as indexed by recoll can be reached.

``search_dir``:
  Part of the indexed file hierarchy to be search, if empty the full domain is
  searched.

Example
=======

Scenario:

#. Recoll indexes a local filesystem mounted in ``/export/documents/reference``,
#. the Recoll search interface can be reached at https://recoll.example.org/ and
#. the contents of this filesystem can be reached though https://download.example.org/reference

.. code:: yaml

   base_url: https://recoll.example.org/
   mount_prefix: /export/documents
   dl_prefix: https://download.example.org
   search_dir: ''

Implementations
===============

Function Documentation

◆ get_time_range()

searx.engines.recoll.get_time_range ( time_range)

Definition at line 79 of file recoll.py.

79def get_time_range(time_range):
80 sw = {'day': 1, 'week': 7, 'month': 30, 'year': 365} # pylint: disable=invalid-name
81
82 offset = sw.get(time_range, 0)
83 if not offset:
84 return ''
85
86 return (date.today() - timedelta(days=offset)).isoformat()
87
88
89# do search-request

Referenced by searx.engines.recoll.request().

+ Here is the caller graph for this function:

◆ request()

searx.engines.recoll.request ( query,
params )

Definition at line 90 of file recoll.py.

90def request(query, params):
91 search_after = get_time_range(params['time_range'])
92 search_url = base_url + 'json?{query}&highlight=0'
93 params['url'] = search_url.format(
94 query=urlencode({'query': query, 'page': params['pageno'], 'after': search_after, 'dir': search_dir})
95 )
96
97 return params
98
99
100# get response from search-request

References searx.engines.recoll.get_time_range().

+ Here is the call graph for this function:

◆ response()

searx.engines.recoll.response ( resp)

Definition at line 101 of file recoll.py.

101def response(resp):
102 results = []
103
104 response_json = loads(resp.text)
105
106 if not response_json:
107 return []
108
109 for result in response_json.get('results', []):
110 title = result['label']
111 url = result['url'].replace('file://' + mount_prefix, dl_prefix)
112 content = '{}'.format(result['snippet'])
113
114 # append result
115 item = {'url': url, 'title': title, 'content': content, 'template': 'files.html'}
116
117 if result['size']:
118 item['size'] = int(result['size'])
119
120 for parameter in ['filename', 'abstract', 'author', 'mtype', 'time']:
121 if result[parameter]:
122 item[parameter] = result[parameter]
123
124 # facilitate preview support for known mime types
125 if 'mtype' in result and '/' in result['mtype']:
126 (mtype, subtype) = result['mtype'].split('/')
127 item['mtype'] = mtype
128 item['subtype'] = subtype
129
130 if mtype in ['audio', 'video']:
131 item['embedded'] = embedded_url.format(
132 ttype=mtype, url=quote(url.encode('utf8'), '/:'), mtype=result['mtype']
133 )
134
135 if mtype in ['image'] and subtype in ['bmp', 'gif', 'jpeg', 'png']:
136 item['thumbnail'] = url
137
138 results.append(item)
139
140 if 'nres' in response_json:
141 results.append({'number_of_results': response_json['nres']})
142
143 return results

References searx.format.

Variable Documentation

◆ about

dict searx.engines.recoll.about
Initial value:
1= {
2 "website": None,
3 "wikidata_id": 'Q15735774',
4 "official_api_documentation": 'https://www.lesbonscomptes.com/recoll/',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 55 of file recoll.py.

◆ base_url

searx.engines.recoll.base_url = None

Definition at line 69 of file recoll.py.

◆ dl_prefix

searx.engines.recoll.dl_prefix = None

Definition at line 72 of file recoll.py.

◆ embedded_url

str searx.engines.recoll.embedded_url = '<{ttype} controls height="166px" ' + 'src="{url}" type="{mtype}"></{ttype}>'

Definition at line 75 of file recoll.py.

◆ mount_prefix

searx.engines.recoll.mount_prefix = None

Definition at line 71 of file recoll.py.

◆ paging

bool searx.engines.recoll.paging = True

Definition at line 65 of file recoll.py.

◆ search_dir

str searx.engines.recoll.search_dir = ''

Definition at line 70 of file recoll.py.

◆ time_range_support

bool searx.engines.recoll.time_range_support = True

Definition at line 66 of file recoll.py.