summaryrefslogtreecommitdiff
path: root/searx/engines/meilisearch.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2025-03-05 17:50:22 +0100
committerMarkus Heiser <markus.heiser@darmarIT.de>2025-03-15 10:36:33 +0100
commitf49b2c94a9a9938133dbf94d686f00776ce96cdc (patch)
tree7b74aa959100bd85054251221981039d185bc50e /searx/engines/meilisearch.py
parentaf5dbdf768d56d26669a54e532bef3238e3de2e4 (diff)
[mod] migrate all key-value.html templates to KeyValue type
The engines now all use KeyValue results and return the results in a EngineResults object. The sqlite engine can return MainResult results in addition to KeyValue results (based on engine's config in settings.yml), Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/meilisearch.py')
-rw-r--r--searx/engines/meilisearch.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/searx/engines/meilisearch.py b/searx/engines/meilisearch.py
index e22674251..1f6c4d8b2 100644
--- a/searx/engines/meilisearch.py
+++ b/searx/engines/meilisearch.py
@@ -33,15 +33,15 @@ Here is a simple example to query a Meilisearch instance:
# pylint: disable=global-statement
-from json import loads, dumps
-
+from json import dumps
+from searx.result_types import EngineResults
+from searx.extended_types import SXNG_Response
base_url = 'http://localhost:7700'
index = ''
auth_key = ''
facet_filters = []
_search_url = ''
-result_template = 'key-value.html'
categories = ['general']
paging = True
@@ -75,13 +75,12 @@ def request(query, params):
return params
-def response(resp):
- results = []
+def response(resp: SXNG_Response) -> EngineResults:
+ res = EngineResults()
- resp_json = loads(resp.text)
- for result in resp_json['hits']:
- r = {key: str(value) for key, value in result.items()}
- r['template'] = result_template
- results.append(r)
+ resp_json = resp.json()
+ for row in resp_json['hits']:
+ kvmap = {key: str(value) for key, value in row.items()}
+ res.add(res.types.KeyValue(kvmap=kvmap))
- return results
+ return res