mirror of
https://github.com/searxng/searxng.git
synced 2024-11-23 04:27:46 +01:00
parent
dd2b106f94
commit
07f5edce3d
1
Makefile
1
Makefile
@ -191,6 +191,7 @@ PYLINT_FILES=\
|
|||||||
searx/engines/google_videos.py \
|
searx/engines/google_videos.py \
|
||||||
searx/engines/google_images.py \
|
searx/engines/google_images.py \
|
||||||
searx/engines/mediathekviewweb.py \
|
searx/engines/mediathekviewweb.py \
|
||||||
|
searx/engines/meilisearch.py \
|
||||||
searx/engines/solidtorrents.py \
|
searx/engines/solidtorrents.py \
|
||||||
searx/engines/solr.py \
|
searx/engines/solr.py \
|
||||||
searx/engines/google_scholar.py \
|
searx/engines/google_scholar.py \
|
||||||
|
59
searx/engines/meilisearch.py
Normal file
59
searx/engines/meilisearch.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"""
|
||||||
|
Meilisearch
|
||||||
|
"""
|
||||||
|
|
||||||
|
# pylint: disable=global-statement, missing-function-docstring
|
||||||
|
|
||||||
|
from json import loads, dumps
|
||||||
|
|
||||||
|
|
||||||
|
base_url = 'http://localhost:7700'
|
||||||
|
index = ''
|
||||||
|
auth_key = ''
|
||||||
|
facet_filters = list()
|
||||||
|
_search_url = ''
|
||||||
|
result_template = 'key-value.html'
|
||||||
|
categories = ['general']
|
||||||
|
paging = True
|
||||||
|
|
||||||
|
|
||||||
|
def init(_):
|
||||||
|
if index == '':
|
||||||
|
raise ValueError('index cannot be empty')
|
||||||
|
|
||||||
|
global _search_url
|
||||||
|
_search_url = base_url + '/indexes/' + index + '/search'
|
||||||
|
|
||||||
|
|
||||||
|
def request(query, params):
|
||||||
|
if auth_key != '':
|
||||||
|
params['headers']['X-Meili-API-Key'] = auth_key
|
||||||
|
|
||||||
|
params['headers']['Content-Type'] = 'application/json'
|
||||||
|
params['url'] = _search_url
|
||||||
|
params['method'] = 'POST'
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'q': query,
|
||||||
|
'offset': 10 * (params['pageno'] - 1),
|
||||||
|
'limit': 10,
|
||||||
|
}
|
||||||
|
if len(facet_filters) > 0:
|
||||||
|
data['facetFilters'] = facet_filters
|
||||||
|
|
||||||
|
params['data'] = dumps(data)
|
||||||
|
|
||||||
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
def response(resp):
|
||||||
|
results = []
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
return results
|
@ -700,6 +700,13 @@ engines:
|
|||||||
require_api_key: false
|
require_api_key: false
|
||||||
results: HTML
|
results: HTML
|
||||||
|
|
||||||
|
# - name : meilisearch
|
||||||
|
# engine : meilisearch
|
||||||
|
# shortcut: mes
|
||||||
|
# enable_http: True
|
||||||
|
# base_url : http://localhost:7700
|
||||||
|
# index : my-index
|
||||||
|
|
||||||
- name : microsoft academic
|
- name : microsoft academic
|
||||||
engine : microsoft_academic
|
engine : microsoft_academic
|
||||||
categories : science
|
categories : science
|
||||||
|
Loading…
Reference in New Issue
Block a user