|
@@ -0,0 +1,45 @@
|
|
1
|
+"""
|
|
2
|
+Open Semantic Search
|
|
3
|
+
|
|
4
|
+ @website https://www.opensemanticsearch.org/
|
|
5
|
+ @provide-api yes (https://www.opensemanticsearch.org/dev)
|
|
6
|
+
|
|
7
|
+ @using-api yes
|
|
8
|
+ @results JSON
|
|
9
|
+ @stable yes
|
|
10
|
+ @parse url, title, content, publishedDate
|
|
11
|
+"""
|
|
12
|
+from dateutil import parser
|
|
13
|
+from json import loads
|
|
14
|
+from searx.url_utils import quote
|
|
15
|
+
|
|
16
|
+base_url = 'http://localhost:8983/solr/opensemanticsearch/'
|
|
17
|
+search_string = 'query?q={query}'
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+def request(query, params):
|
|
21
|
+ search_path = search_string.format(
|
|
22
|
+ query=quote(query),
|
|
23
|
+ )
|
|
24
|
+ params['url'] = base_url + search_path
|
|
25
|
+ return params
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+def response(resp):
|
|
29
|
+ results = []
|
|
30
|
+ data = loads(resp.text)
|
|
31
|
+ docs = data.get('response', {}).get('docs', [])
|
|
32
|
+
|
|
33
|
+ for current in docs:
|
|
34
|
+ item = {}
|
|
35
|
+ item['url'] = current['id']
|
|
36
|
+ item['title'] = current['title_txt_txt_en']
|
|
37
|
+ if current.get('content_txt'):
|
|
38
|
+ item['content'] = current['content_txt'][0]
|
|
39
|
+ item['publishedDate'] = parser.parse(
|
|
40
|
+ current['file_modified_dt']
|
|
41
|
+ )
|
|
42
|
+ item['originalData'] = current
|
|
43
|
+ results.append(item)
|
|
44
|
+
|
|
45
|
+ return results
|