meilisearch 0.1.0 meilisearch: ^0.1.0 copied to clipboard
MeiliSearch SDK for dart language.
MeiliSearch Dart
MeiliSearch | Documentation | Roadmap | Website | Blog | Twitter | FAQ
⚡ The MeiliSearch API client written for Dart
MeiliSearch Dart is the MeiliSearch API client for Dart developers. Which you can also use for your Flutter apps as well. MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, facets, and synonyms are provided out-of-the-box.
📖 Documentation #
See our Documentation or our API References.
🔧 Installation #
You can install meilisearch package by adding a few lines into pubspec.yaml
file.
dependencies:
meilisearch: ">=0.0.1 <2.0.0"
Then open your terminal and update dart packages.
$ pub get
Run MeiliSearch #
There are many easy ways to download and run a MeiliSearch instance.
For example, if you use Docker:
$ docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub
$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey
NB: you can also download MeiliSearch from Homebrew or APT.
🚀 Getting Started #
Add Documents
import 'package:meilisearch/meilisearch.dart';
void main() async {
var client = MeiliSearchClient('http://127.0.0.1:7700', 'masterKey');
// An index where books are stored.
var index = await client.createIndex('books', primaryKey: 'book_id');
var documents = [
{ 'book_id': 123, 'title': 'Pride and Prejudice' },
{ 'book_id': 456, 'title': 'Le Petit Prince' },
{ 'book_id': 1, 'title': 'Alice In Wonderland' },
{ 'book_id': 1344, 'title': 'The Hobbit' },
{ 'book_id': 4, 'title': 'Harry Potter and the Half-Blood Prince' },
{ 'book_id': 42, 'title': 'The Hitchhiker\'s Guide to the Galaxy' }
];
// Add documents into index we just created.
var update = await index.addDocuments(documents);
}
Basic Search
// MeiliSearch is typo-tolerant:
var result = await index.search('harry pottre');
print(result.hits);
Output:
[
{
"book_id": 4,
"title": "Harry Potter and the Half-Blood Prince"
}
]
Custom Search
All the supported options are described in the search parameters section of the documentation.
var result = index.search(
'prince',
attributesToHighlight: ['title'],
filters: 'book_id > 10',
);