mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
Merge #197
197: Update milli (v0.3.1) with filterable attributes r=MarinPostma a=curquiza Fixes #187 and #70 Also fixes #195 Co-authored-by: Clémentine Urquizar <clementine@meilisearch.com>
This commit is contained in:
commit
b119bb4ab0
10 changed files with 64 additions and 48 deletions
|
@ -50,7 +50,7 @@
|
|||
"wolverine": ["xmen", "logan"],
|
||||
"logan": ["wolverine", "xmen"]
|
||||
},
|
||||
"attributesForFaceting": [
|
||||
"filterableAttributes": [
|
||||
"gender",
|
||||
"color",
|
||||
"tags",
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
{"status": "processed","updateId": 0,"type": {"name":"Settings","settings":{"ranking_rules":{"Update":["Typo","Words","Proximity","Attribute","WordsPosition","Exactness"]},"distinct_attribute":"Nothing","primary_key":"Nothing","searchable_attributes":{"Update":["balance","picture","age","color","name","gender","email","phone","address","about","registered","latitude","longitude","tags"]},"displayed_attributes":{"Update":["about","address","age","balance","color","email","gender","id","isActive","latitude","longitude","name","phone","picture","registered","tags"]},"stop_words":"Nothing","synonyms":"Nothing","attributes_for_faceting":"Nothing"}}}
|
||||
{"status": "processed", "updateId": 1, "type": { "name": "DocumentsAddition"}}
|
||||
{"status": "processed","updateId": 0,"type": {"name":"Settings","settings":{"ranking_rules":{"Update":["Typo","Words","Proximity","Attribute","WordsPosition","Exactness"]},"distinct_attribute":"Nothing","primary_key":"Nothing","searchable_attributes":{"Update":["balance","picture","age","color","name","gender","email","phone","address","about","registered","latitude","longitude","tags"]},"displayed_attributes":{"Update":["about","address","age","balance","color","email","gender","id","isActive","latitude","longitude","name","phone","picture","registered","tags"]},"stop_words":"Nothing","synonyms":"Nothing","filterable_attributes":"Nothing"}}}
|
||||
{"status": "processed", "updateId": 1, "type": { "name": "DocumentsAddition"}}
|
||||
|
|
|
@ -19,7 +19,7 @@ async fn get_settings() {
|
|||
assert_eq!(settings.keys().len(), 6);
|
||||
assert_eq!(settings["displayedAttributes"], json!(["*"]));
|
||||
assert_eq!(settings["searchableAttributes"], json!(["*"]));
|
||||
assert_eq!(settings["attributesForFaceting"], json!({}));
|
||||
assert_eq!(settings["filterableAttributes"], json!([]));
|
||||
assert_eq!(settings["distinctAttribute"], json!(null));
|
||||
assert_eq!(
|
||||
settings["rankingRules"],
|
||||
|
@ -72,26 +72,44 @@ async fn delete_settings_unexisting_index() {
|
|||
async fn reset_all_settings() {
|
||||
let server = Server::new().await;
|
||||
let index = server.index("test");
|
||||
index
|
||||
.update_settings(json!({"displayedAttributes": ["foo"], "searchableAttributes": ["bar"], "stopWords": ["the"], "attributesForFaceting": { "toto": "string" } }))
|
||||
.await;
|
||||
|
||||
let documents = json!([
|
||||
{
|
||||
"id": 1,
|
||||
"name": "curqui",
|
||||
"age": 99
|
||||
}
|
||||
]);
|
||||
|
||||
let (response, code) = index.add_documents(documents, None).await;
|
||||
assert_eq!(code, 202);
|
||||
assert_eq!(response["updateId"], 0);
|
||||
index.wait_update_id(0).await;
|
||||
|
||||
index
|
||||
.update_settings(json!({"displayedAttributes": ["name", "age"], "searchableAttributes": ["name"], "stopWords": ["the"], "filterableAttributes": ["age"] }))
|
||||
.await;
|
||||
index.wait_update_id(1).await;
|
||||
let (response, code) = index.settings().await;
|
||||
assert_eq!(code, 200);
|
||||
assert_eq!(response["displayedAttributes"], json!(["foo"]));
|
||||
assert_eq!(response["searchableAttributes"], json!(["bar"]));
|
||||
assert_eq!(response["displayedAttributes"], json!(["name", "age"]));
|
||||
assert_eq!(response["searchableAttributes"], json!(["name"]));
|
||||
assert_eq!(response["stopWords"], json!(["the"]));
|
||||
assert_eq!(response["attributesForFaceting"], json!({"toto": "string"}));
|
||||
assert_eq!(response["filterableAttributes"], json!(["age"]));
|
||||
|
||||
index.delete_settings().await;
|
||||
index.wait_update_id(1).await;
|
||||
index.wait_update_id(2).await;
|
||||
|
||||
let (response, code) = index.settings().await;
|
||||
assert_eq!(code, 200);
|
||||
assert_eq!(response["displayedAttributes"], json!(["*"]));
|
||||
assert_eq!(response["searchableAttributes"], json!(["*"]));
|
||||
assert_eq!(response["stopWords"], json!([]));
|
||||
assert_eq!(response["attributesForFaceting"], json!({}));
|
||||
assert_eq!(response["filterableAttributes"], json!([]));
|
||||
|
||||
let (response, code) = index.get_document(1, None).await;
|
||||
assert_eq!(code, 200);
|
||||
assert!(response.as_object().unwrap().get("age").is_some());
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
|
@ -163,7 +181,7 @@ macro_rules! test_setting_routes {
|
|||
}
|
||||
|
||||
test_setting_routes!(
|
||||
attributes_for_faceting,
|
||||
filterable_attributes,
|
||||
displayed_attributes,
|
||||
searchable_attributes,
|
||||
stop_words
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue