mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Merge #515
515: Improve the README r=curquiza a=Kerollmops This PR closes #512 by adding more content to the README. We listed all of the subcrates of the repository, changed the descriptions of the subcrates, and added a simple example usage in the README. Co-authored-by: Kerollmops <clement@meilisearch.com> Co-authored-by: Clémentine Urquizar - curqui <clementine@meilisearch.com>
This commit is contained in:
commit
8cc86d5a8d
72
README.md
72
README.md
@ -15,14 +15,78 @@ to process one update at a time.
|
||||
|
||||
This repository contains crates to quickly debug the engine:
|
||||
- There are benchmarks located in the `benchmarks` crate.
|
||||
- The `http-ui` crate is a simple HTTP dashboard to tests the features like for real!
|
||||
- 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 `helpers` crate is only used to do operations on the database.
|
||||
- The `http-ui` crate is a simple HTTP dashboard to test the features like for real!
|
||||
- The `infos` crate is used to dump the internal data-structure and ensure correctness.
|
||||
- The `search` crate is a simple command-line that helps run [flamegraph] on top of it.
|
||||
- The `helpers` crate is only used to modify the database inplace, sometimes.
|
||||
- The `json-depth-checker` crate is used to indicate if a JSON must be flattened.
|
||||
|
||||
## How to use it?
|
||||
|
||||
_Section in WIP_
|
||||
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
|
||||
and search for one of them right after.
|
||||
|
||||
```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",
|
||||
"au{hor": "Jane Austin",
|
||||
"genre": "romance",
|
||||
"price$": "3.5$",
|
||||
},
|
||||
{
|
||||
"id": 456,
|
||||
"title": "Le Petit Prince",
|
||||
"au{hor": "Antoine de Saint-Exupéry",
|
||||
"genre": "adventure",
|
||||
"price$": "10.0$",
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Wonderland",
|
||||
"au{hor": "Lewis Carroll",
|
||||
"genre": "fantasy",
|
||||
"price$": "25.99$",
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Harry Potter ing fantasy\0lood Prince",
|
||||
"au{hor": "J. K. Rowling",
|
||||
"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);
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
|
@ -4,8 +4,6 @@ version = "0.26.1"
|
||||
edition = "2018"
|
||||
description = "A CLI to interact with a milli index"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
indicatif = "0.16.2"
|
||||
serde = "1.0.136"
|
||||
|
@ -2,8 +2,7 @@
|
||||
name = "filter-parser"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
description = "The parser for the Meilisearch filter syntax"
|
||||
|
||||
[dependencies]
|
||||
nom = "7.1.0"
|
||||
|
@ -3,6 +3,7 @@ name = "helpers"
|
||||
version = "0.26.1"
|
||||
authors = ["Clément Renault <clement@meilisearch.com>"]
|
||||
edition = "2018"
|
||||
description = "A small tool to do operations on the database"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.56"
|
||||
|
@ -2,8 +2,7 @@
|
||||
name = "json-depth-checker"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
description = "A library that indicates if a JSON must be flattened"
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
|
@ -1,6 +1,6 @@
|
||||
use serde_json::Value;
|
||||
|
||||
/// Your json MUST BE valid and generated by `serde_json::to_vec` before being
|
||||
/// Your json MUST BE valid and generated by `serde_json::to_vec` before being
|
||||
/// sent in this function. This function is DUMB and FAST but makes a lot of
|
||||
/// asumption about the way `serde_json` will generate its input.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user