From 8e15d3e4c1ed077a42d67fdad19fa6ab00f91261 Mon Sep 17 00:00:00 2001 From: Nicholas Kegler Date: Thu, 14 Jun 2018 15:32:20 -0300 Subject: [PATCH] Open Semantic Search Engine --- searx/engines/opensemantic.py | 42 +++++++++++++++++++++++++++++++++++ searx/settings.yml | 5 +++++ 2 files changed, 47 insertions(+) create mode 100644 searx/engines/opensemantic.py diff --git a/searx/engines/opensemantic.py b/searx/engines/opensemantic.py new file mode 100644 index 000000000..9364bab41 --- /dev/null +++ b/searx/engines/opensemantic.py @@ -0,0 +1,42 @@ +""" +Open Semantic Search + + @website https://www.opensemanticsearch.org/ + @provide-api yes (https://www.opensemanticsearch.org/dev) + + @using-api yes + @results JSON + @stable yes + @parse url, title, content, publishedDate +""" +from dateutil import parser +from json import loads +from urllib.parse import quote + +base_url = 'http://localhost:8983/solr/opensemanticsearch/' +search_string = 'query?q={query}' + + +def request(query, params): + search_path = search_string.format( + query=quote(query), + ) + params['url'] = base_url + search_path + return params + + +def response(resp): + results = [] + data = loads(resp.text) + docs = data.get('response', {}).get('docs', []) + + for current in docs: + item = {} + item['url'] = current['id'] + item['title'] = current['title_txt_txt_en'] + if current.get('content_txt'): + item['content'] = current['content_txt'][0] + item['publishedDate'] = parser.parse(current['file_modified_dt']) + results.append(item) + + return results diff --git a/searx/settings.yml b/searx/settings.yml index aa5f35256..a599ab285 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -540,6 +540,11 @@ engines: shortcut : oap timeout: 5.0 +# - name : opensemanticsearch +# engine : opensemantic +# shortcut : oss +# base_url : 'http://localhost:8983/solr/opensemanticsearch/' + - name : openstreetmap engine : openstreetmap shortcut : osm