2020-08-04 15:40:02 +02:00
< p align = "center" >
2022-10-04 12:20:24 +02:00
< img alt = "the milli logo" src = "assets/logo-black.svg" >
2020-08-04 15:40:02 +02:00
< / p >
2020-11-02 18:06:10 +01:00
< p align = "center" > a concurrent indexer combined with fast and relevant search algorithms< / p >
2020-06-28 12:40:08 +02:00
## Introduction
2022-01-26 17:47:26 +01:00
This repository contains the core engine used in [Meilisearch].
2020-06-28 12:40:08 +02:00
2022-01-26 17:47:26 +01:00
It contains a library that can manage one and only one index. Meilisearch
2021-08-17 16:49:17 +02:00
manages the multi-index itself. Milli is unable to store updates in a store:
it is the job of something else above and this is why it is only able
to process one update at a time.
This repository contains crates to quickly debug the engine:
2022-10-03 09:38:59 +05:30
- There are benchmarks located in the `benchmarks` crate.
- The `cli` crate is a simple command-line interface that helps run [flamegraph] on top of it.
- The `filter-parser` crate contains the parser for the Meilisearch filter syntax.
- The `flatten-serde-json` crate contains the library that flattens serde-json `Value` objects like Elasticsearch does.
- The `json-depth-checker` crate is used to indicate if a JSON must be flattened.
2021-08-17 16:49:17 +02:00
2022-04-21 19:02:22 +02:00
## How to use it?
2020-11-02 18:06:10 +01:00
2022-04-25 17:25:46 +02:00
Milli is a library that does search things, it must be embedded in a program.
You can compute the documentation of it by using `cargo doc --open` .
Here is an example usage of the library where we insert documents into the engine
2022-04-25 18:14:43 +02:00
and search for one of them right after.
2022-04-25 17:25:46 +02:00
```rust
let path = tempfile::tempdir().unwrap();
let mut options = EnvOpenOptions::new();
options.map_size(10 * 1024 * 1024); // 10 MB
let index = Index::new(options, &path).unwrap();
let mut wtxn = index.write_txn().unwrap();
let content = documents!([
{
"id": 2,
"title": "Prideand Prejudice",
2022-10-03 09:38:59 +05:30
"author": "Jane Austin",
2022-04-25 17:25:46 +02:00
"genre": "romance",
"price$": "3.5$",
},
{
"id": 456,
"title": "Le Petit Prince",
2022-10-03 09:38:59 +05:30
"author": "Antoine de Saint-Exupéry",
2022-04-25 17:25:46 +02:00
"genre": "adventure",
"price$": "10.0$",
},
{
"id": 1,
"title": "Wonderland",
2022-10-03 09:38:59 +05:30
"author": "Lewis Carroll",
2022-04-25 17:25:46 +02:00
"genre": "fantasy",
"price$": "25.99$",
},
{
"id": 4,
"title": "Harry Potter ing fantasy\0lood Prince",
2022-10-03 09:38:59 +05:30
"author": "J. K. Rowling",
2022-04-25 17:25:46 +02:00
"genre": "fantasy\0",
},
]);
let config = IndexerConfig::default();
let indexing_config = IndexDocumentsConfig::default();
let mut builder =
IndexDocuments::new(& mut wtxn, & index, & config, indexing_config.clone(), |_| ())
.unwrap();
builder.add_documents(content).unwrap();
builder.execute().unwrap();
wtxn.commit().unwrap();
// You can search in the index now!
let mut rtxn = index.read_txn().unwrap();
let mut search = Search::new(& rtxn, &index);
search.query("horry");
search.limit(10);
let result = search.execute().unwrap();
assert_eq!(result.documents_ids.len(), 1);
```
2021-06-16 18:33:33 +02:00
## Contributing
2022-04-21 19:02:22 +02:00
We're glad you're thinking about contributing to this repository! Feel free to pick an issue, and to ask any question you need. Some points might not be clear and we are available to help you!
2021-06-16 18:33:33 +02:00
2022-04-21 19:02:22 +02:00
Also, we recommend following the [CONTRIBUTING.md ](/CONTRIBUTING.md ) to create your PR.
2021-08-17 16:49:17 +02:00
2022-10-03 09:52:20 +05:30
[Meilisearch]: https://github.com/meilisearch/meilisearch
2021-08-17 16:49:17 +02:00
[flamegraph]: https://github.com/flamegraph-rs/flamegraph