From fb192aaa9f7772a0ad4d72b32c9245ce5134c4b6 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Mon, 25 Apr 2022 15:55:38 +0200 Subject: [PATCH 1/5] Update the list of milli's subcrates --- README.md | 7 +++++-- cli/Cargo.toml | 2 -- filter-parser/Cargo.toml | 3 +-- helpers/Cargo.toml | 1 + json-depth-checker/Cargo.toml | 3 +-- json-depth-checker/src/lib.rs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4bf6a0d70..31e71b603 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,13 @@ 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 `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 elastic search does. + - The `helpers` crate is only used to do operations on the database. - The `http-ui` crate is a simple HTTP dashboard to tests 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? diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 06ac4ddb5..de302b895 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -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" diff --git a/filter-parser/Cargo.toml b/filter-parser/Cargo.toml index ea29404ed..fe069ccb2 100644 --- a/filter-parser/Cargo.toml +++ b/filter-parser/Cargo.toml @@ -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" diff --git a/helpers/Cargo.toml b/helpers/Cargo.toml index ea58d874d..d71009c91 100644 --- a/helpers/Cargo.toml +++ b/helpers/Cargo.toml @@ -3,6 +3,7 @@ name = "helpers" version = "0.26.1" authors = ["Clément Renault "] edition = "2018" +description = "A small tool to do operations on the database" [dependencies] anyhow = "1.0.56" diff --git a/json-depth-checker/Cargo.toml b/json-depth-checker/Cargo.toml index d608a49dc..9d99a47d8 100644 --- a/json-depth-checker/Cargo.toml +++ b/json-depth-checker/Cargo.toml @@ -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" diff --git a/json-depth-checker/src/lib.rs b/json-depth-checker/src/lib.rs index 3d0f28af8..d571a0ca5 100644 --- a/json-depth-checker/src/lib.rs +++ b/json-depth-checker/src/lib.rs @@ -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. /// From 7e19bf1c0eadc9f2da84fef0395ef508aebd17a9 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Mon, 25 Apr 2022 17:25:46 +0200 Subject: [PATCH 2/5] Add an example usage of the library in the README --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 31e71b603..20b12329b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,68 @@ This repository contains crates to quickly debug the engine: ## 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 just 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 From 2db3d602593f4f25eea346122b2b3ff00e15ba09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar=20-=20curqui?= Date: Mon, 25 Apr 2022 18:14:35 +0200 Subject: [PATCH 3/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 20b12329b..fbc2587d9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This repository contains crates to quickly debug the engine: - 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 elastic search does. + - 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 tests the features like for real! - The `infos` crate is used to dump the internal data-structure and ensure correctness. From 2277172f9c76c4bba7a8dedea37968bef830940e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar=20-=20curqui?= Date: Mon, 25 Apr 2022 18:14:39 +0200 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fbc2587d9..08c78bd10 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ This repository contains crates to quickly debug the engine: - 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 tests the features like for real! + - 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 `json-depth-checker` crate is used to indicate if a JSON must be flattened. From 5e562ffecfa60495a1d7d23602abce86f364bd8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar=20-=20curqui?= Date: Mon, 25 Apr 2022 18:14:43 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 08c78bd10..5e916905d 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ 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 just after. +and search for one of them right after. ```rust let path = tempfile::tempdir().unwrap();