.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.meilisearch Namespace Reference

Functions

 init (_)
 
 request (query, params)
 
 response (resp)
 

Variables

str base_url = 'http://localhost:7700'
 
str index = ''
 
str auth_key = ''
 
list facet_filters = []
 
str _search_url = ''
 
str result_template = 'key-value.html'
 
list categories = ['general']
 
bool paging = True
 

Detailed Description

.. sidebar:: info

   - :origin:`meilisearch.py <searx/engines/meilisearch.py>`
   - `MeiliSearch <https://www.meilisearch.com>`_
   - `MeiliSearch Documentation <https://docs.meilisearch.com/>`_
   - `Install MeiliSearch
     <https://docs.meilisearch.com/learn/getting_started/installation.html>`_

MeiliSearch_ is aimed at individuals and small companies.  It is designed for
small-scale (less than 10 million documents) data collections.  E.g. it is great
for storing web pages you have visited and searching in the contents later.

The engine supports faceted search, so you can search in a subset of documents
of the collection.  Furthermore, you can search in MeiliSearch_ instances that
require authentication by setting ``auth_token``.

Example
=======

Here is a simple example to query a Meilisearch instance:

.. code:: yaml

  - name: meilisearch
    engine: meilisearch
    shortcut: mes
    base_url: http://localhost:7700
    index: my-index
    enable_http: true

Function Documentation

◆ init()

searx.engines.meilisearch.init ( _)

Definition at line 49 of file meilisearch.py.

49def init(_):
50 if index == '':
51 raise ValueError('index cannot be empty')
52
53 global _search_url
54 _search_url = base_url + '/indexes/' + index + '/search'
55
56

◆ request()

searx.engines.meilisearch.request ( query,
params )

Definition at line 57 of file meilisearch.py.

57def request(query, params):
58 if auth_key != '':
59 params['headers']['X-Meili-API-Key'] = auth_key
60
61 params['headers']['Content-Type'] = 'application/json'
62 params['url'] = _search_url
63 params['method'] = 'POST'
64
65 data = {
66 'q': query,
67 'offset': 10 * (params['pageno'] - 1),
68 'limit': 10,
69 }
70 if len(facet_filters) > 0:
71 data['facetFilters'] = facet_filters
72
73 params['data'] = dumps(data)
74
75 return params
76
77

◆ response()

searx.engines.meilisearch.response ( resp)

Definition at line 78 of file meilisearch.py.

78def response(resp):
79 results = []
80
81 resp_json = loads(resp.text)
82 for result in resp_json['hits']:
83 r = {key: str(value) for key, value in result.items()}
84 r['template'] = result_template
85 results.append(r)
86
87 return results

Variable Documentation

◆ _search_url

str searx.engines.meilisearch._search_url = ''
protected

Definition at line 43 of file meilisearch.py.

◆ auth_key

str searx.engines.meilisearch.auth_key = ''

Definition at line 41 of file meilisearch.py.

◆ base_url

str searx.engines.meilisearch.base_url = 'http://localhost:7700'

Definition at line 39 of file meilisearch.py.

◆ categories

list searx.engines.meilisearch.categories = ['general']

Definition at line 45 of file meilisearch.py.

◆ facet_filters

list searx.engines.meilisearch.facet_filters = []

Definition at line 42 of file meilisearch.py.

◆ index

str searx.engines.meilisearch.index = ''

Definition at line 40 of file meilisearch.py.

◆ paging

bool searx.engines.meilisearch.paging = True

Definition at line 46 of file meilisearch.py.

◆ result_template

str searx.engines.meilisearch.result_template = 'key-value.html'

Definition at line 44 of file meilisearch.py.