Skip to content

Commit facc65c

Browse files
authored
Merge branch 'faceting2' into issue-502
2 parents a9c570f + 6eb41e8 commit facc65c

File tree

20 files changed

+1518
-178
lines changed

20 files changed

+1518
-178
lines changed

.code-samples.meilisearch.yaml

Lines changed: 174 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ update_settings_1: |-
337337
"release_date"
338338
])
339339
.with_synonyms(synonyms)
340-
.with_typo_tolerance(typo_tolerance);
340+
.with_typo_tolerance(typo_tolerance)
341+
.with_search_cutoff(150);
341342
342343
let task: TaskInfo = client
343344
.index("movies")
@@ -599,6 +600,42 @@ reset_faceting_settings_1: |-
599600
.reset_faceting()
600601
.await
601602
.unwrap();
603+
get_separator_tokens_1: |-
604+
let task: TaskInfo = client
605+
.index('articles')
606+
.get_separator_tokens()
607+
.await
608+
.unwrap();
609+
update_separator_tokens_1: |-
610+
let task: TaskInfo = client
611+
.index('articles')
612+
.set_separator_tokens(&vec!['|'.to_string(), '…'.to_string()])
613+
.await
614+
.unwrap();
615+
reset_separator_tokens_1: |-
616+
let task: TaskInfo = client
617+
.index('articles')
618+
.reset_separator_tokens()
619+
.await
620+
.unwrap();
621+
get_non_separator_tokens_1: |-
622+
let task: TaskInfo = client
623+
.index('articles')
624+
.get_non_separator_tokens()
625+
.await
626+
.unwrap();
627+
update_non_separator_tokens_1: |-
628+
let task: TaskInfo = client
629+
.index('articles')
630+
.set_non_separator_tokens(&vec!['@'.to_string(), '#'.to_string()])
631+
.await
632+
.unwrap();
633+
reset_non_separator_tokens_1: |-
634+
let task: TaskInfo = client
635+
.index('articles')
636+
.reset_non_separator_tokens()
637+
.await
638+
.unwrap();
602639
get_dictionary_1: |-
603640
let task: TaskInfo = client
604641
.index('books')
@@ -843,6 +880,15 @@ search_parameter_guide_show_ranking_score_1: |-
843880
.execute()
844881
.await
845882
.unwrap();
883+
search_parameter_guide_show_ranking_score_details_1: |-
884+
let results: SearchResults<Movie> = client
885+
.index("movies")
886+
.search()
887+
.with_query("dragon")
888+
.with_show_ranking_score_details(true)
889+
.execute()
890+
.await
891+
.unwrap();
846892
search_parameter_guide_matching_strategy_1: |-
847893
let results: SearchResults<Movie> = client
848894
.index("movies")
@@ -861,6 +907,15 @@ search_parameter_guide_matching_strategy_2: |-
861907
.execute()
862908
.await
863909
.unwrap();
910+
search_parameter_guide_matching_strategy_3: |-
911+
let results: SearchResults<Movie> = client
912+
.index("movies")
913+
.search()
914+
.with_query("white shirt")
915+
.with_matching_strategy(MatchingStrategies::FREQUENCY)
916+
.execute()
917+
.await
918+
.unwrap();
864919
search_parameter_guide_hitsperpage_1: |-
865920
client.index("movies").search().with_hits_per_page(15).execute().await?;
866921
search_parameter_guide_page_1: |-
@@ -994,10 +1049,10 @@ primary_field_guide_add_document_primary_key: |-
9941049
], Some("reference_number"))
9951050
.await
9961051
.unwrap();
997-
getting_started_add_documents_md: |-
998-
```toml
1052+
getting_started_add_documents: |-
1053+
// In your .toml file:
9991054
[dependencies]
1000-
meilisearch-sdk = "0.26.1"
1055+
meilisearch-sdk = "0.28.0"
10011056
# futures: because we want to block on futures
10021057
futures = "0.3"
10031058
# serde: required if you are going to use documents
@@ -1006,9 +1061,8 @@ getting_started_add_documents_md: |-
10061061
serde_json = "1.0"
10071062
```
10081063
1009-
Documents in the Rust library are strongly typed.
1010-
1011-
```rust
1064+
// In your .rs file:
1065+
// Documents in the Rust library are strongly typed
10121066
#[derive(Serialize, Deserialize)]
10131067
struct Movie {
10141068
id: i64,
@@ -1018,23 +1072,17 @@ getting_started_add_documents_md: |-
10181072
release_date: i64,
10191073
genres: Vec<String>
10201074
}
1021-
```
10221075
1023-
You will often need this `Movie` struct in other parts of this documentation. (you will have to change it a bit sometimes)
1024-
You can also use schemaless values, by putting a `serde_json::Value` inside your own struct like this:
1025-
1026-
```rust
1076+
// You will often need this `Movie` struct in other parts of this documentation. (you will have to change it a bit sometimes)
1077+
// You can also use schemaless values, by putting a `serde_json::Value` inside your own struct like this:
10271078
#[derive(Serialize, Deserialize)]
10281079
struct Movie {
10291080
id: i64,
10301081
#[serde(flatten)]
10311082
value: serde_json::Value,
10321083
}
1033-
```
1034-
1035-
Then, add documents into the index:
10361084
1037-
```rust
1085+
// Then, add documents into the index:
10381086
use meilisearch_sdk::{
10391087
indexes::*,
10401088
client::*,
@@ -1048,7 +1096,7 @@ getting_started_add_documents_md: |-
10481096
fn main() { block_on(async move {
10491097
let client = Client::new("http://localhost:7700", Some("aSampleMasterKey"));
10501098
1051-
// reading and parsing the file
1099+
// Reading and parsing the file
10521100
let mut file = File::open("movies.json")
10531101
.unwrap();
10541102
let mut content = String::new();
@@ -1058,19 +1106,15 @@ getting_started_add_documents_md: |-
10581106
let movies_docs: Vec<Movie> = serde_json::from_str(&content)
10591107
.unwrap();
10601108
1061-
// adding documents
1109+
// Adding documents
10621110
client
10631111
.index("movies")
10641112
.add_documents(&movies_docs, None)
10651113
.await
10661114
.unwrap();
10671115
})}
1068-
```
1069-
1070-
[About this SDK](https://github.com/meilisearch/meilisearch-rust/)
1071-
getting_started_search_md: |-
1072-
You can build a `SearchQuery` and execute it later:
1073-
```rust
1116+
getting_started_search: |-
1117+
// You can build a `SearchQuery` and execute it later:
10741118
let query: SearchQuery = SearchQuery::new(&movies)
10751119
.with_query("botman")
10761120
.build();
@@ -1080,29 +1124,22 @@ getting_started_search_md: |-
10801124
.execute_query(&query)
10811125
.await
10821126
.unwrap();
1083-
```
10841127
1085-
You can build a `SearchQuery` and execute it directly:
1086-
```rust
1128+
// You can build a `SearchQuery` and execute it directly:
10871129
let results: SearchResults<Movie> = SearchQuery::new(&movies)
10881130
.with_query("botman")
10891131
.execute()
10901132
.await
10911133
.unwrap();
1092-
```
10931134
1094-
You can search in an index directly:
1095-
```rust
1135+
// You can search in an index directly:
10961136
let results: SearchResults<Movie> = client
10971137
.index("movies")
10981138
.search()
10991139
.with_query("botman")
11001140
.execute()
11011141
.await
11021142
.unwrap();
1103-
```
1104-
1105-
[About this SDK](https://github.com/meilisearch/meilisearch-rust/)
11061143
getting_started_update_ranking_rules: |-
11071144
let ranking_rules = [
11081145
"exactness",
@@ -1601,8 +1638,8 @@ get_experimental_features_1: |-
16011638
.unwrap();
16021639
update_experimental_features_1: |-
16031640
let client = Client::new("http://localhost:7700", Some("apiKey"));
1604-
let mut features = ExperimentalFeatures::new(&client);
1605-
features.set_vector_store(true);
1641+
let features = ExperimentalFeatures::new(&client);
1642+
features.set_metrics(true)
16061643
let res = features
16071644
.update()
16081645
.await
@@ -1633,9 +1670,12 @@ reset_proximity_precision_settings_1: |-
16331670
.reset_proximity_precision()
16341671
.await
16351672
.unwrap();
1636-
create_snapshot_1: |-
1637-
client
1638-
.create_snapshot()
1673+
facet_search_1: |-
1674+
let res = client.index("books")
1675+
.facet_search("genres")
1676+
.with_facet_query("fiction")
1677+
.with_filter("rating > 3")
1678+
.execute()
16391679
.await
16401680
.unwrap();
16411681
facet_search_2: |-
@@ -1652,3 +1692,99 @@ facet_search_2: |-
16521692
.execute()
16531693
.await
16541694
.unwrap();
1695+
facet_search_3: |-
1696+
let res = client.index("books")
1697+
.facet_search("genres")
1698+
.with_facet_query("c")
1699+
.execute()
1700+
.await
1701+
.unwrap();
1702+
get_search_cutoff_1: |-
1703+
let search_cutoff_ms: String = client
1704+
.index("movies")
1705+
.get_search_cutoff_ms()
1706+
.await
1707+
.unwrap();
1708+
update_search_cutoff_1: |-
1709+
let task: TaskInfo = client
1710+
.index("movies")
1711+
.set_search_cutoff_ms(Some(150))
1712+
.await
1713+
.unwrap();
1714+
reset_search_cutoff_1: |-
1715+
let task: TaskInfo = client
1716+
.index("movies")
1717+
.reset_search_cutoff_ms()
1718+
.await
1719+
.unwrap();
1720+
create_snapshot_1: |-
1721+
client
1722+
.create_snapshot()
1723+
.await
1724+
.unwrap();
1725+
search_parameter_reference_distinct_1: |-
1726+
let res = client
1727+
.index("INDEX_NAME")
1728+
.search()
1729+
.with_query("QUERY TERMS")
1730+
.with_distinct("ATTRIBUTE_A")
1731+
.execute()
1732+
.await
1733+
.unwrap();
1734+
distinct_attribute_guide_filterable_1: |-
1735+
let task: TaskInfo = client
1736+
.index("products")
1737+
.settings()
1738+
.set_filterable_attributes(["product_id", "sku", "url"])
1739+
.execute()
1740+
.await
1741+
.unwrap();
1742+
distinct_attribute_guide_distinct_parameter_1: |-
1743+
let res = client
1744+
.index("products")
1745+
.search()
1746+
.with_query("white shirt")
1747+
.with_distinct("sku")
1748+
.execute()
1749+
.await
1750+
.unwrap();
1751+
search_parameter_reference_ranking_score_threshold_1: |-
1752+
let res = client
1753+
.index("INDEX_NAME")
1754+
.search()
1755+
.with_query("badman")
1756+
.with_ranking_score_threshold(0.2)
1757+
.execute()
1758+
.await
1759+
.unwrap();
1760+
search_parameter_reference_locales_1: |-
1761+
let res = client
1762+
.index("books")
1763+
.search()
1764+
.with_query("進撃の巨人")
1765+
.with_locales(&["jpn"])
1766+
.execute()
1767+
.await
1768+
.unwrap();
1769+
get_localized_attribute_settings_1: |-
1770+
let localized_attributes: Option<Vec<LocalizedAttributes>> = client
1771+
.index("books")
1772+
.get_localized_attributes()
1773+
.await
1774+
.unwrap();
1775+
update_localized_attribute_settings_1: |-
1776+
let localized_attributes = vec![LocalizedAttributes {
1777+
locales: vec!["jpn".to_string()],
1778+
attribute_patterns: vec!["*_ja".to_string()],
1779+
}];
1780+
let task: TaskInfo = client
1781+
.index("books")
1782+
.set_localized_attributes(&localizced_attributes)
1783+
.await
1784+
.unwrap();
1785+
reset_localized_attribute_settings_1: |-
1786+
let task: TaskInfo = client
1787+
.index("books")
1788+
.reset_localized_attributes()
1789+
.await
1790+
.unwrap();

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[package]
22
name = "meilisearch-sdk"
3-
version = "0.26.1"
3+
version = "0.28.0"
44
authors = ["Mubelotix <mubelotix@gmail.com>"]
55
edition = "2018"
66
description = "Rust wrapper for the Meilisearch API. Meilisearch is a powerful, fast, open-source, easy to use and deploy search engine."
77
license = "MIT"
88
readme = "README.md"
99
repository = "https://github.com/meilisearch/meilisearch-sdk"
10+
resolver = "2"
1011

1112
[workspace]
1213
members = ["examples/*"]
@@ -21,7 +22,7 @@ time = { version = "0.3.7", features = ["serde-well-known", "formatting", "parsi
2122
yaup = "0.3.1"
2223
either = { version = "1.8.0", features = ["serde"] }
2324
thiserror = "1.0.37"
24-
meilisearch-index-setting-macro = { path = "meilisearch-index-setting-macro", version = "0.26.1" }
25+
meilisearch-index-setting-macro = { path = "meilisearch-index-setting-macro", version = "0.28.0" }
2526
pin-project-lite = { version = "0.2.13", optional = true }
2627
reqwest = { version = "0.12.3", optional = true, default-features = false, features = ["rustls-tls", "http2", "stream"] }
2728
bytes = { version = "1.6", optional = true }

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020-2024 Meili SAS
3+
Copyright (c) 2020-2025 Meili SAS
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)