.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
opensemantic.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""Open Semantic Search
3
4"""
5
6from json import loads
7from urllib.parse import quote
8from dateutil import parser
9
10# about
11about = {
12 "website": 'https://www.opensemanticsearch.org/',
13 "wikidata_id": None,
14 "official_api_documentation": 'https://www.opensemanticsearch.org/dev',
15 "use_official_api": True,
16 "require_api_key": False,
17 "results": 'JSON',
18}
19
20base_url = 'http://localhost:8983/solr/opensemanticsearch/'
21search_string = 'query?q={query}'
22
23
24def request(query, params):
25 search_path = search_string.format(
26 query=quote(query),
27 )
28 params['url'] = base_url + search_path
29 return params
30
31
32def response(resp):
33 results = []
34 data = loads(resp.text)
35 docs = data.get('response', {}).get('docs', [])
36
37 for current in docs:
38 item = {}
39 item['url'] = current['id']
40 item['title'] = current['title_txt_txt_en']
41 if current.get('content_txt'):
42 item['content'] = current['content_txt'][0]
43 item['publishedDate'] = parser.parse(current['file_modified_dt'])
44 results.append(item)
45
46 return results