1
1
# This code-samples file is used by the Meilisearch documentation
2
2
# Every example written here will be automatically fetched by
3
3
# the documentation on build
4
- # You can read more on https://github.com/meilisearch/documentation/tree/master/.vuepress/code-samples
4
+ # You can read more on https://github.com/meilisearch/documentation/tree/main/learn
5
5
---
6
6
synonyms_guide_1 : |-
7
7
let mut synonyms = std::collections::HashMap::new();
@@ -595,6 +595,24 @@ reset_faceting_settings_1: |-
595
595
.reset_faceting()
596
596
.await
597
597
.unwrap();
598
+ get_dictionary_1 : |-
599
+ let task: TaskInfo = client
600
+ .index('books')
601
+ .get_dictionary()
602
+ .await
603
+ .unwrap();
604
+ update_dictionary_1 : |-
605
+ let task: TaskInfo = client
606
+ .index('books')
607
+ .set_dictionary(['J. R. R.', 'W. E. B.'])
608
+ .await
609
+ .unwrap();
610
+ reset_dictionary_1 : |-
611
+ let task: TaskInfo = client
612
+ .index('books')
613
+ .reset_dictionary()
614
+ .await
615
+ .unwrap();
598
616
get_index_stats_1 : |-
599
617
let stats: IndexStats = client
600
618
.index("movies")
@@ -650,7 +668,7 @@ field_properties_guide_displayed_1: |-
650
668
.unwrap();
651
669
filtering_guide_1 : |-
652
670
let results: SearchResults<Movie> = client
653
- .index("movies ")
671
+ .index("movie_ratings ")
654
672
.search()
655
673
.with_query("Avengers")
656
674
.with_filter("release_date > 795484800")
@@ -659,7 +677,7 @@ filtering_guide_1: |-
659
677
.unwrap();
660
678
filtering_guide_2 : |-
661
679
let results: SearchResults<Movie> = client
662
- .index("movies ")
680
+ .index("movie_ratings ")
663
681
.search()
664
682
.with_query("Batman")
665
683
.with_filter(r#"release_date > 795484800 AND (director = "Tim Burton" OR director = "Christopher Nolan")"#)
@@ -668,10 +686,10 @@ filtering_guide_2: |-
668
686
.unwrap();
669
687
filtering_guide_3 : |-
670
688
let results: SearchResults<Movie> = client
671
- .index("movies ")
689
+ .index("movie_ratings ")
672
690
.search()
673
691
.with_query("Planet of the Apes")
674
- .with_filter(r#"rating >= 3 AND (NOT director = "Tim Burton")"#)
692
+ .with_filter(r#"release_date > 1577884550 AND (NOT director = "Tim Burton")"#)
675
693
.execute()
676
694
.await
677
695
.unwrap();
@@ -692,6 +710,15 @@ search_parameter_guide_query_1: |-
692
710
.execute()
693
711
.await
694
712
.unwrap();
713
+ search_parameter_guide_attributes_to_search_on_1 : |-
714
+ let results: SearchResults<Movie> = client
715
+ .index("movies")
716
+ .search()
717
+ .with_query("adventure")
718
+ .with_attributes_to_search_on(&["overview"])
719
+ .execute()
720
+ .await
721
+ .unwrap();
695
722
search_parameter_guide_offset_1 : |-
696
723
let results: SearchResults<Movie> = client
697
724
.index("movies")
@@ -803,6 +830,15 @@ search_parameter_guide_show_matches_position_1: |-
803
830
.iter()
804
831
.map(|r| r.matches_position.as_ref().unwrap())
805
832
.collect();
833
+ search_parameter_guide_show_ranking_score_1 : |-
834
+ let results: SearchResults<Movie> = client
835
+ .index("movies")
836
+ .search()
837
+ .with_query("dragon")
838
+ .with_show_ranking_score(true)
839
+ .execute()
840
+ .await
841
+ .unwrap();
806
842
search_parameter_guide_matching_strategy_1 : |-
807
843
let results: SearchResults<Movie> = client
808
844
.index("movies")
@@ -825,38 +861,6 @@ search_parameter_guide_hitsperpage_1: |-
825
861
client.index("movies").search().with_hits_per_page(15).execute().await?;
826
862
search_parameter_guide_page_1 : |-
827
863
client.index("movies").search().with_page(2).execute().await?;
828
- settings_guide_filterable_attributes_1 : |-
829
- let settings = Settings::new()
830
- .with_filterable_attributes([
831
- "director",
832
- "genres"
833
- ]);
834
-
835
- let task: TaskInfo = client
836
- .index("movies")
837
- .set_settings(&settings)
838
- .await
839
- .unwrap();
840
- settings_guide_typo_tolerance_1 : |-
841
- let min_word_size_for_typos = MinWordSizeForTypos {
842
- one_typo: Some(5),
843
- two_typos: Some(12)
844
- }
845
- let typo_tolerance = TypoToleranceSettings {
846
- enabled: Some(true),
847
- disable_on_attributes: None,
848
- disable_on_words: Some(vec!["title".to_string()]),
849
- min_word_size_for_typos: Some(min_word_size_for_typos),
850
- };
851
-
852
- let settings = Settings::new()
853
- .with_typo_tolerance(&typo_tolerance);
854
-
855
- let task: TaskInfo = client
856
- .index("movies")
857
- .set_settings(&settings)
858
- .await
859
- .unwrap();
860
864
typo_tolerance_guide_1 : |-
861
865
let typo_tolerance = TypoToleranceSettings {
862
866
enabled: Some(false),
@@ -898,7 +902,7 @@ typo_tolerance_guide_3: |-
898
902
disable_on_words: Some(vec!["shrek".to_string()]),
899
903
min_word_size_for_typos: Some(min_word_size_for_typos),
900
904
};
901
-
905
+
902
906
let task: TaskInfo = client
903
907
.index("movies")
904
908
.set_typo_tolerance(&typo_tolerance)
@@ -952,25 +956,6 @@ add_movies_json_1: |-
952
956
.await
953
957
.unwrap();
954
958
})}
955
- documents_guide_add_movie_1 : |-
956
- // Define the type of our documents
957
- #[derive(Serialize, Deserialize)]
958
- struct IncompleteMovie {
959
- id: String,
960
- title: String
961
- }
962
-
963
- // Add a document to our index
964
- let task: TaskInfo = client
965
- .index("movies")
966
- .add_documents(&[
967
- IncompleteMovie {
968
- id: "123sq178".to_string(),
969
- title: "Amélie Poulain".to_string(),
970
- }
971
- ], None)
972
- .await
973
- .unwrap();
974
959
primary_field_guide_update_document_primary_key : |-
975
960
let task = IndexUpdater::new("books", &client)
976
961
.with_primary_key("title")
@@ -1008,7 +993,7 @@ primary_field_guide_add_document_primary_key: |-
1008
993
getting_started_add_documents_md : |-
1009
994
```toml
1010
995
[dependencies]
1011
- meilisearch-sdk = "0.24.1 "
996
+ meilisearch-sdk = "0.25.0 "
1012
997
# futures: because we want to block on futures
1013
998
futures = "0.3"
1014
999
# serde: required if you are going to use documents
@@ -1057,7 +1042,7 @@ getting_started_add_documents_md: |-
1057
1042
use futures::executor::block_on;
1058
1043
1059
1044
fn main() { block_on(async move {
1060
- let client = Client::new("http://localhost:7700", Some("masterKey "));
1045
+ let client = Client::new("http://localhost:7700", Some("aSampleMasterKey "));
1061
1046
1062
1047
// reading and parsing the file
1063
1048
let mut file = File::open("movies.json")
@@ -1175,11 +1160,6 @@ getting_started_update_displayed_attributes: |-
1175
1160
.set_displayed_attributes(&displayed_attributes)
1176
1161
.await
1177
1162
.unwrap();
1178
- getting_started_communicating_with_a_protected_instance : |-
1179
- let client = Client::new("http://localhost:7700", Some("apiKey"));
1180
- client
1181
- .index("movies")
1182
- .search()
1183
1163
getting_started_add_meteorites : |-
1184
1164
use serde::{Serialize, Deserialize};
1185
1165
use std::fs::File;
@@ -1279,28 +1259,6 @@ filtering_update_settings_1: |-
1279
1259
.set_filterable_attributes(["director", "genres"])
1280
1260
.await
1281
1261
.unwrap();
1282
- faceted_search_filter_1 : |-
1283
- let results: SearchResults<Movie> = client
1284
- .index("movies")
1285
- .search()
1286
- .with_query("thriller")
1287
- .with_filter("(genres = Horror AND genres = Mystery) OR director = \"Jordan Peele\"")
1288
- .execute()
1289
- .await
1290
- .unwrap();
1291
- faceted_search_facets_1 : |-
1292
- let results: SearchResults<Movie> = client
1293
- .index("movies")
1294
- .search()
1295
- .with_query("Batman")
1296
- .with_facets(Selectors::Some(&["genres"]))
1297
- .execute()
1298
- .await
1299
- .unwrap();
1300
- let genres: &HashMap<String, usize> = results
1301
- .facet_distribution.unwrap()
1302
- .get("genres")
1303
- .unwrap();
1304
1262
faceted_search_walkthrough_filter_1 : |-
1305
1263
let results: SearchResults<Movie> = client
1306
1264
.index("movies")
@@ -1312,7 +1270,7 @@ faceted_search_walkthrough_filter_1: |-
1312
1270
.unwrap();
1313
1271
faceted_search_update_settings_1 : |-
1314
1272
let task: TaskInfo = client
1315
- .index("books ")
1273
+ .index("movie_ratings ")
1316
1274
.set_filterable_attributes(&["genres", "rating", "language"])
1317
1275
.await
1318
1276
.unwrap();
@@ -1325,29 +1283,6 @@ faceted_search_1: |-
1325
1283
.execute()
1326
1284
.await
1327
1285
.unwrap();
1328
- faceted_search_2 : |-
1329
- let books = client.index("books");
1330
- let search_query_1 = SearchQuery::new(&books)
1331
- .with_facets(Selectors::Some(&["language", "genres", "author", "format"]))
1332
- .with_filter("(language = English OR language = French) AND genres = Fiction")
1333
- .build();
1334
- let search_query_2 = SearchQuery::new(&books)
1335
- .with_facets(Selectors::Some(&["language"]))
1336
- .with_filter("genres = Fiction")
1337
- .build();
1338
- let search_query_3 = SearchQuery::new(&books)
1339
- .with_facets(Selectors::Some(&["genres"]))
1340
- .with_filter("language = English OR language = French")
1341
- .build();
1342
-
1343
- let books_response = client
1344
- .multi_search()
1345
- .with_search_query(search_query_1)
1346
- .with_search_query(search_query_2)
1347
- .with_search_query(search_query_3)
1348
- .execute::<Book>()
1349
- .await
1350
- .unwrap();
1351
1286
post_dump_1 : |-
1352
1287
client
1353
1288
.create_dump()
@@ -1494,7 +1429,7 @@ geosearch_guide_filter_usage_3: |-
1494
1429
let results: SearchResults<Restaurant> = client
1495
1430
.index("restaurants")
1496
1431
.search()
1497
- .with_filter("_geoBoundingBox([45.494181, 9.179175 ], [45.449484, 9.214024 ])")
1432
+ .with_filter("_geoBoundingBox([45.494181, 9.214024 ], [45.449484, 9.179175 ])")
1498
1433
.execute()
1499
1434
.await
1500
1435
.unwrap();
@@ -1510,8 +1445,9 @@ get_all_keys_1: |-
1510
1445
.await
1511
1446
.unwrap();
1512
1447
create_a_key_1 : |-
1513
- let mut key_options = KeyBuilder::new("Add documents: Products API key" );
1448
+ let mut key_options = KeyBuilder::new();
1514
1449
key_options
1450
+ .with_name("Add documents: Products API key")
1515
1451
.with_action(Action::DocumentsAdd)
1516
1452
.with_expires_at(time::macros::datetime!(2042 - 04 - 02 00:42:42 UTC))
1517
1453
.with_index("products");
@@ -1562,8 +1498,9 @@ security_guide_update_key_1: |-
1562
1498
.update(&client);
1563
1499
security_guide_create_key_1 : |-
1564
1500
let client = Client::new("http://localhost:7700", Some("masterKey"));
1565
- let mut key_options = KeyBuilder::new("Search patient records key" );
1501
+ let mut key_options = KeyBuilder::new();
1566
1502
key_options
1503
+ .with_name("Search patient records key")
1567
1504
.with_action(Action::Search)
1568
1505
.with_expires_at(time::macros::datetime!(2023 - 01 - 01 00:00:00 UTC))
1569
1506
.with_index("patient_medical_records");
@@ -1626,31 +1563,66 @@ tenant_token_guide_search_sdk_1: |-
1626
1563
.unwrap();
1627
1564
multi_search_1 : |-
1628
1565
let movie = client.index("movie");
1566
+ let movie_ratings = client.index("movie_ratings");
1567
+
1629
1568
let search_query_1 = SearchQuery::new(&movie)
1630
1569
.with_query("pooh")
1631
1570
.with_limit(5)
1632
1571
.build();
1633
1572
let search_query_2 = SearchQuery::new(&movie)
1634
1573
.with_query("nemo")
1635
- .with_limit(5)
1574
+ .with_limit(5)
1575
+ .build();
1576
+ let search_query_3 = SearchQuery::new(&movie_ratings)
1577
+ .with_query("us")
1636
1578
.build();
1637
1579
1638
- let movie_response = client
1580
+ let response = client
1639
1581
.multi_search()
1640
1582
.with_search_query(search_query_1)
1641
1583
.with_search_query(search_query_2)
1642
- .execute::<Movie>()
1584
+ .with_search_query(search_query_3)
1585
+ .execute::<Document>()
1643
1586
.await
1644
1587
.unwrap();
1645
-
1646
- let movie_ratings = client.index("movie_ratings");
1647
- let search_query_3 = SearchQuery::new(&movie_ratings)
1648
- .with_query("us")
1649
- .build();
1650
-
1651
- let movie_ratings_response = client
1652
- .multi_search()
1653
- .with_search_query(search_query_3)
1654
- .execute::<MovieRatings>()
1588
+ get_experimental_features_1 : |-
1589
+ let client = Client::new("http://localhost:7700", Some("apiKey"));
1590
+ let features = ExperimentalFeatures::new(&client);
1591
+ let res = features
1592
+ .get()
1593
+ .await
1594
+ .unwrap();
1595
+ update_experimental_features_1 : |-
1596
+ let client = Client::new("http://localhost:7700", Some("apiKey"));
1597
+ let mut features = ExperimentalFeatures::new(&client);
1598
+ features.set_vector_store(true);
1599
+ let res = features
1600
+ .update()
1601
+ .await
1602
+ .unwrap();
1603
+ search_parameter_guide_facet_stats_1 : |-
1604
+ let books = client.index("movie_ratings");
1605
+ let results: SearchResults<Book> = SearchQuery::new(&books)
1606
+ .with_query("Batman")
1607
+ .with_facets(Selectors::Some(&["genres", "rating"))
1608
+ .execute()
1609
+ .await
1610
+ .unwrap();
1611
+ get_proximity_precision_settings_1 : |-
1612
+ let proximity_precision: String = client
1613
+ .index("books")
1614
+ .get_typo_tolerance()
1615
+ .await
1616
+ .unwrap();
1617
+ update_proximity_precision_settings_1 : |-
1618
+ let task: TaskInfo = client
1619
+ .index("books")
1620
+ .set_proximity_precision("byAttribute".to_string())
1621
+ .await
1622
+ .unwrap();
1623
+ reset_proximity_precision_settings_1 : |-
1624
+ let task: TaskInfo = client
1625
+ .index("books")
1626
+ .reset_proximity_precision()
1655
1627
.await
1656
1628
.unwrap();
0 commit comments