Skip to content

Commit 4d3d9d1

Browse files
authored
Merge branch 'facet-settings' into facet-prefix-search-626
2 parents d11887c + 0c278ff commit 4d3d9d1

File tree

14 files changed

+1231
-116
lines changed

14 files changed

+1231
-116
lines changed

.code-samples.meilisearch.yaml

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Every example written here will be automatically fetched by
33
# the documentation on build
44
# You can read more on https://github.com/meilisearch/documentation/tree/main/learn
5+
# See the original at https://github.com/meilisearch/documentation/blob/main/.code-samples.meilisearch.yaml
56
---
67
synonyms_guide_1: |-
78
let mut synonyms = std::collections::HashMap::new();
@@ -581,8 +582,12 @@ get_faceting_settings_1: |-
581582
.await
582583
.unwrap();
583584
update_faceting_settings_1: |-
585+
let mut facet_sort_setting = BTreeMap::new();
586+
facet_sort_setting.insert(String::from("*"), FacetSortValue::Alpha);
587+
facet_sort_setting.insert(String::from("genres"), FacetSortValue::Count);
584588
let mut faceting = FacetingSettings {
585589
max_values_per_facet: 2,
590+
sort_facet_values_by: Some(facet_sort_setting),
586591
};
587592
588593
let task: TaskInfo = client
@@ -1045,8 +1050,8 @@ primary_field_guide_add_document_primary_key: |-
10451050
], Some("reference_number"))
10461051
.await
10471052
.unwrap();
1048-
getting_started_add_documents_md: |-
1049-
```toml
1053+
getting_started_add_documents: |-
1054+
// In your .toml file:
10501055
[dependencies]
10511056
meilisearch-sdk = "0.28.0"
10521057
# futures: because we want to block on futures
@@ -1057,9 +1062,8 @@ getting_started_add_documents_md: |-
10571062
serde_json = "1.0"
10581063
```
10591064
1060-
Documents in the Rust library are strongly typed.
1061-
1062-
```rust
1065+
// In your .rs file:
1066+
// Documents in the Rust library are strongly typed
10631067
#[derive(Serialize, Deserialize)]
10641068
struct Movie {
10651069
id: i64,
@@ -1069,23 +1073,17 @@ getting_started_add_documents_md: |-
10691073
release_date: i64,
10701074
genres: Vec<String>
10711075
}
1072-
```
1073-
1074-
You will often need this `Movie` struct in other parts of this documentation. (you will have to change it a bit sometimes)
1075-
You can also use schemaless values, by putting a `serde_json::Value` inside your own struct like this:
10761076
1077-
```rust
1077+
// You will often need this `Movie` struct in other parts of this documentation. (you will have to change it a bit sometimes)
1078+
// You can also use schemaless values, by putting a `serde_json::Value` inside your own struct like this:
10781079
#[derive(Serialize, Deserialize)]
10791080
struct Movie {
10801081
id: i64,
10811082
#[serde(flatten)]
10821083
value: serde_json::Value,
10831084
}
1084-
```
1085-
1086-
Then, add documents into the index:
10871085
1088-
```rust
1086+
// Then, add documents into the index:
10891087
use meilisearch_sdk::{
10901088
indexes::*,
10911089
client::*,
@@ -1099,7 +1097,7 @@ getting_started_add_documents_md: |-
10991097
fn main() { block_on(async move {
11001098
let client = Client::new("http://localhost:7700", Some("aSampleMasterKey"));
11011099
1102-
// reading and parsing the file
1100+
// Reading and parsing the file
11031101
let mut file = File::open("movies.json")
11041102
.unwrap();
11051103
let mut content = String::new();
@@ -1109,19 +1107,15 @@ getting_started_add_documents_md: |-
11091107
let movies_docs: Vec<Movie> = serde_json::from_str(&content)
11101108
.unwrap();
11111109
1112-
// adding documents
1110+
// Adding documents
11131111
client
11141112
.index("movies")
11151113
.add_documents(&movies_docs, None)
11161114
.await
11171115
.unwrap();
11181116
})}
1119-
```
1120-
1121-
[About this SDK](https://github.com/meilisearch/meilisearch-rust/)
1122-
getting_started_search_md: |-
1123-
You can build a `SearchQuery` and execute it later:
1124-
```rust
1117+
getting_started_search: |-
1118+
// You can build a `SearchQuery` and execute it later:
11251119
let query: SearchQuery = SearchQuery::new(&movies)
11261120
.with_query("botman")
11271121
.build();
@@ -1131,29 +1125,22 @@ getting_started_search_md: |-
11311125
.execute_query(&query)
11321126
.await
11331127
.unwrap();
1134-
```
11351128
1136-
You can build a `SearchQuery` and execute it directly:
1137-
```rust
1129+
// You can build a `SearchQuery` and execute it directly:
11381130
let results: SearchResults<Movie> = SearchQuery::new(&movies)
11391131
.with_query("botman")
11401132
.execute()
11411133
.await
11421134
.unwrap();
1143-
```
11441135
1145-
You can search in an index directly:
1146-
```rust
1136+
// You can search in an index directly:
11471137
let results: SearchResults<Movie> = client
11481138
.index("movies")
11491139
.search()
11501140
.with_query("botman")
11511141
.execute()
11521142
.await
11531143
.unwrap();
1154-
```
1155-
1156-
[About this SDK](https://github.com/meilisearch/meilisearch-rust/)
11571144
getting_started_update_ranking_rules: |-
11581145
let ranking_rules = [
11591146
"exactness",
@@ -1283,8 +1270,11 @@ getting_started_sorting: |-
12831270
.await
12841271
.unwrap();
12851272
getting_started_faceting: |-
1273+
let mut facet_sort_setting = BTreeMap::new();
1274+
facet_sort_setting.insert("*".to_string(), FacetSortValue::Count);
12861275
let mut faceting = FacetingSettings {
12871276
max_values_per_facet: 2,
1277+
sort_facet_values_by: Some(facet_sort_setting),
12881278
};
12891279
12901280
let task: TaskInfo = client
@@ -1650,7 +1640,7 @@ get_experimental_features_1: |-
16501640
update_experimental_features_1: |-
16511641
let client = Client::new("http://localhost:7700", Some("apiKey"));
16521642
let features = ExperimentalFeatures::new(&client);
1653-
// update the feature you want here
1643+
features.set_metrics(true)
16541644
let res = features
16551645
.update()
16561646
.await
@@ -1717,6 +1707,33 @@ reset_prefix_search_settings_1: |-
17171707
.reset_prefix_search()
17181708
.await
17191709
.unwrap();
1710+
facet_search_1: |-
1711+
let res = client.index("books")
1712+
.facet_search("genres")
1713+
.with_facet_query("fiction")
1714+
.with_filter("rating > 3")
1715+
.execute()
1716+
.await
1717+
.unwrap();
1718+
facet_search_2: |-
1719+
let mut facet_sort_setting = BTreeMap::new();
1720+
facet_sort_setting.insert("genres".to_string(), FacetSortValue::Count);
1721+
let faceting = FacetingSettings {
1722+
max_values_per_facet: 100,
1723+
sort_facet_values_by: Some(facet_sort_setting),
1724+
};
1725+
1726+
let res = client.index("books")
1727+
.set_faceting(&faceting)
1728+
.await
1729+
.unwrap();
1730+
facet_search_3: |-
1731+
let res = client.index("books")
1732+
.facet_search("genres")
1733+
.with_facet_query("c")
1734+
.execute()
1735+
.await
1736+
.unwrap();
17201737
get_search_cutoff_1: |-
17211738
let search_cutoff_ms: String = client
17221739
.index("movies")

.github/workflows/tests.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,36 @@ jobs:
8383
uses: ibiqlik/action-yamllint@v3
8484
with:
8585
config_file: .yamllint.yml
86+
87+
coverage:
88+
# Will not run if the actor is Dependabot (dependabot PRs)
89+
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
90+
if: github.actor != 'dependabot[bot]' && !( github.event_name == 'pull_request' && startsWith(github.base_ref, 'bump-meilisearch-v') )
91+
runs-on: ubuntu-latest
92+
needs: integration_tests
93+
name: Code Coverage
94+
steps:
95+
- uses: actions/checkout@v4
96+
# Nightly Rust is used for cargo llvm-cov --doc below.
97+
- uses: dtolnay/rust-toolchain@nightly
98+
with:
99+
components: llvm-tools-preview
100+
- name: Install cargo-llvm-cov
101+
uses: taiki-e/install-action@v2
102+
with:
103+
tool: cargo-llvm-cov
104+
- name: Meilisearch (latest version) setup with Docker
105+
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --no-analytics --master-key=masterKey
106+
- name: Collect coverage data
107+
# Generate separate reports for tests and doctests, and combine them.
108+
run: |
109+
set -euo pipefail
110+
cargo llvm-cov --no-report --all-features --workspace
111+
cargo llvm-cov --no-report --doc --all-features --workspace
112+
cargo llvm-cov report --doctests --codecov --output-path codecov.json
113+
- name: Upload coverage reports to Codecov
114+
uses: codecov/codecov-action@v5
115+
with:
116+
token: ${{ secrets.CODECOV_TOKEN }}
117+
files: codecov.json
118+
fail_ci_if_error: true

Cargo.toml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ resolver = "2"
1313
members = ["examples/*"]
1414

1515
[dependencies]
16-
async-trait = "0.1.51"
17-
iso8601 = "0.6.1"
18-
log = "0.4"
16+
async-trait = "0.1.88"
17+
iso8601 = "0.6.3"
18+
log = "0.4.27"
1919
serde = { version = "1.0", features = ["derive"] }
20-
serde_json = "1.0"
21-
time = { version = "0.3.7", features = ["serde-well-known", "formatting", "parsing"] }
20+
serde_json = "1.0.140"
21+
time = { version = "0.3.41", features = ["serde-well-known", "formatting", "parsing"] }
2222
yaup = "0.3.1"
23-
either = { version = "1.8.0", features = ["serde"] }
24-
thiserror = "1.0.37"
25-
meilisearch-index-setting-macro = { path = "meilisearch-index-setting-macro", version = "0.28.0" }
26-
pin-project-lite = { version = "0.2.13", optional = true }
27-
reqwest = { version = "0.12.3", optional = true, default-features = false, features = ["rustls-tls", "http2", "stream"] }
28-
bytes = { version = "1.6", optional = true }
29-
uuid = { version = "1.1.2", features = ["v4"] }
30-
futures-io = "0.3.30"
31-
futures = "0.3"
23+
either = { version = "1.15.0", features = ["serde"] }
24+
thiserror = "2.0.12"
25+
meilisearch-index-setting-macro.path = "meilisearch-index-setting-macro"
26+
pin-project-lite = { version = "0.2.16", optional = true }
27+
reqwest = { version = "0.12.22", optional = true, default-features = false, features = ["rustls-tls", "http2", "stream"] }
28+
bytes = { version = "1.10.1", optional = true }
29+
uuid = { version = "1.17.0", features = ["v4"] }
30+
futures-io = "0.3.31"
31+
futures = "0.3.31"
3232

3333
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
34-
jsonwebtoken = { version = "9", default-features = false }
34+
jsonwebtoken = { version = "9.3.1", default-features = false }
3535

3636
[target.'cfg(target_arch = "wasm32")'.dependencies]
37-
uuid = { version = "1.8.0", default-features = false, features = ["v4", "js"] }
38-
web-sys = "0.3"
37+
uuid = { version = "1.17.0", default-features = false, features = ["v4", "js"] }
38+
web-sys = "0.3.77"
3939
wasm-bindgen-futures = "0.4"
4040

4141
[features]
@@ -46,9 +46,9 @@ futures-unsend = []
4646
[dev-dependencies]
4747
futures-await-test = "0.3"
4848
futures = "0.3"
49-
mockito = "1.0.0"
49+
mockito = "1.0"
5050
meilisearch-test-macro = { path = "meilisearch-test-macro" }
51-
tokio = { version = "1", features = ["rt", "macros"] }
51+
tokio = { version = "1.46", features = ["rt", "macros"] }
5252

5353
# The following dependencies are required for examples
5454
wasm-bindgen = "0.2"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<a href="https://github.com/meilisearch/meilisearch-rust/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
2525
<a href="https://github.com/meilisearch/meilisearch/discussions" alt="Discussions"><img src="https://img.shields.io/badge/github-discussions-red" /></a>
2626
<a href="https://ms-bors.herokuapp.com/repositories/62"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
27+
<a href="https://codecov.io/gh/meilisearch/meilisearch-rust"><img src="https://codecov.io/gh/meilisearch/meilisearch-rust/graph/badge.svg?token=NVO9OI8JMG"/></a>
2728
</p>
2829

2930
<p align="center">⚡ The Meilisearch API client written for Rust 🦀</p>

README.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<a href="https://github.com/meilisearch/meilisearch-rust/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
2525
<a href="https://github.com/meilisearch/meilisearch/discussions" alt="Discussions"><img src="https://img.shields.io/badge/github-discussions-red" /></a>
2626
<a href="https://ms-bors.herokuapp.com/repositories/62"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
27+
<a href="https://codecov.io/gh/meilisearch/meilisearch-rust"><img src="https://codecov.io/gh/meilisearch/meilisearch-rust/graph/badge.svg?token=NVO9OI8JMG"/></a>
2728
</p>
2829

2930
<p align="center">⚡ The Meilisearch API client written for Rust 🦀</p>

meilisearch-index-setting-macro/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ repository = "https://github.com/meilisearch/meilisearch-rust"
1212
proc-macro = true
1313

1414
[dependencies]
15-
syn = { version = "2.0.48", features = ["extra-traits"] }
16-
quote = "1.0.21"
17-
proc-macro2 = "1.0.46"
18-
convert_case = "0.6.0"
15+
syn = { version = "2.0.104", features = ["extra-traits"] }
16+
quote = "1.0.40"
17+
proc-macro2 = "1.0.95"
18+
convert_case = "0.8.0"
1919
structmeta = "0.3"

meilisearch-test-macro/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ proc-macro = true
1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

1212
[dependencies]
13-
proc-macro2 = "1.0.0"
14-
quote = "1.0.0"
15-
syn = { version = "2.0.48", features = ["clone-impls", "full", "parsing", "printing", "proc-macro"], default-features = false }
13+
proc-macro2 = "1.0.95"
14+
quote = "1.0.40"
15+
syn = { version = "2.0.104", features = ["clone-impls", "full", "parsing", "printing", "proc-macro"], default-features = false }

src/client.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,9 +1118,17 @@ impl<Http: HttpClient> Client<Http> {
11181118
#[derive(Debug, Clone, Deserialize)]
11191119
#[serde(rename_all = "camelCase")]
11201120
pub struct ClientStats {
1121+
/// Storage space claimed by Meilisearch and LMDB in bytes
11211122
pub database_size: usize,
1123+
1124+
/// Storage space used by the database in bytes, excluding unused space claimed by LMDB
1125+
pub used_database_size: usize,
1126+
1127+
/// When the last update was made to the database in the `RFC 3339` format
11221128
#[serde(with = "time::serde::rfc3339::option")]
11231129
pub last_update: Option<OffsetDateTime>,
1130+
1131+
/// The statistics for each index found in the database
11241132
pub indexes: HashMap<String, IndexStats>,
11251133
}
11261134

0 commit comments

Comments
 (0)