Service: Meilisearch - EyevinnOSC/community GitHub Wiki
Meilisearch
Meilisearch (serviceId meilisearch-meilisearch) is a fast, typo-tolerant search engine for developers, with built-in ranking, filtering and faceting. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance with up to 10 GiB of storage per instance.
What it can do
- Add search to an application through a REST API and SDKs, with sub-50ms results.
- Typo tolerance, filtering, faceting, ranking and hybrid search.
- Fine-grained access control: use the master key to create scoped API keys for applications.
- Serve a Mini Dashboard in the browser at the instance URL.
Creating an instance
Meilisearch has no dependencies on other OSC services. It requires a master key of at least 16 characters, the root authentication credential. Generate one, for example:
openssl rand -hex 32
Store it with create-service-secret (serviceId meilisearch-meilisearch, name masterkey), then create the instance with create-service-instance using serviceId: "meilisearch-meilisearch". The name must be alphanumeric and at most 20 characters.
{ "name": "mysearch", "MasterKey": "{{secrets.masterkey}}" }
Wait with wait-for-service-ready, then use describe-service-instance for the URL. OSC CLI form: osc create meilisearch-meilisearch mysearch -o MasterKey="your-master-key-at-least-16-chars".
Options
| Option | Required | Type | Meaning |
|---|---|---|---|
| name | Yes | string | Name of the instance. Letters, digits and underscore only, at most 20 characters. |
| MasterKey | Yes | string, sensitive | Master API key, the root credential with full access to all operations; also used to create other API keys with scoped permissions. At least 16 characters. Pass as {{secrets.NAME}}, which only works as the entire field value. |
Using the instance
Open the instance URL in a browser for the Meilisearch Mini Dashboard and authenticate with the master key. Index documents:
curl -X POST 'https://<your-meilisearch-url>/indexes/movies/documents' \
-H 'Authorization: Bearer <your-master-key>' \
-H 'Content-Type: application/json' \
--data '[
{"id": 1, "title": "Carol", "genre": "Drama"},
{"id": 2, "title": "Wonder Woman", "genre": "Action"},
{"id": 3, "title": "Inception", "genre": "Sci-Fi"}
]'
Search:
curl 'https://<your-meilisearch-url>/indexes/movies/search?q=wonder' \
-H 'Authorization: Bearer <your-master-key>'
JavaScript:
import { MeiliSearch } from 'meilisearch';
const client = new MeiliSearch({
host: 'https://<your-meilisearch-url>',
apiKey: '<your-master-key>'
});
const results = await client.index('movies').search('wonder');
console.log(results.hits);
Create a scoped API key for an application:
curl -X POST 'https://<your-meilisearch-url>/keys' \
-H 'Authorization: Bearer <your-master-key>' \
-H 'Content-Type: application/json' \
--data '{
"actions": ["search"],
"indexes": ["movies"],
"expiresAt": null
}'
Limitations
- Storage is limited to 10 GiB per instance.