test distinct attribute
@@ -469,3 +469,19 @@ async fn setting_ranking_rules_dont_mess_with_other_settings() {
assert!(!response["searchableAttributes"].as_array().unwrap().iter().any(|e| e.as_str().unwrap() == "foobar"));
assert!(!response["displayedAttributes"].as_array().unwrap().iter().any(|e| e.as_str().unwrap() == "foobar"));
}
+
+#[actix_rt::test]
+async fn distinct_attribute_recorded_as_known_field() {
+ let mut server = common::Server::test_server().await;
+ let body = json!({
+ "distinctAttribute": "foobar",
+ "acceptNewFields": true
+ });
+ server.update_all_settings(body).await;
+ let document = json!([{"id": 9348127, "foobar": "hello", "foo": "bar"}]);
+ server.add_or_update_multiple_documents(document).await;
+ // foobar should not be added to the searchable attributes because it is already known, but "foo" should
+ let (response, _) = server.get_all_settings().await;
+ assert!(response["searchableAttributes"].as_array().unwrap().iter().any(|v| v.as_str().unwrap() == "foo"));
+ assert!(!response["searchableAttributes"].as_array().unwrap().iter().any(|v| v.as_str().unwrap() == "foobar"));
+}
