Index document in filterable attributes tests

**Reason:**
Because the filterable attributes are patterns now,
the fieldIdMap will only register the fields that exists in at least one document.
if a field doesn't exist in any document, it will not be registered even if it has been specified in the filterable fields.
This commit is contained in:
ManyTheFish 2025-02-27 16:50:50 +01:00
parent 9a75dc6ab3
commit 6dbec91d2b
3 changed files with 35 additions and 14 deletions

View file

@ -1,8 +1,10 @@
use meili_snap::*;
use crate::common::{shared_does_not_exists_index, Server};
use crate::common::{shared_does_not_exists_index, Server, DOCUMENTS, NESTED_DOCUMENTS};
use crate::json;
use super::test_settings_documents_indexing_swapping_and_search;
#[actix_rt::test]
async fn search_unexisting_index() {
let index = shared_does_not_exists_index().await;
@ -422,6 +424,8 @@ async fn search_invalid_threshold() {
async fn search_non_filterable_facets() {
let server = Server::new_shared();
let index = server.unique_index();
let (response, _code) = index.add_documents(json!([{"id": 1, "title": "Doggo"}]), None).await;
index.wait_task(response.uid()).await.succeeded();
let (response, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
// Wait for the settings update to complete
index.wait_task(response.uid()).await.succeeded();
@ -453,6 +457,9 @@ async fn search_non_filterable_facets() {
async fn search_non_filterable_facets_multiple_filterable() {
let server = Server::new_shared();
let index = server.unique_index();
let (response, _code) =
index.add_documents(json!([{"id": 1, "title": "Doggo", "genres": "Action"}]), None).await;
index.wait_task(response.uid()).await.succeeded();
let (response, _code) =
index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await;
index.wait_task(response.uid()).await.succeeded();
@ -514,6 +521,9 @@ async fn search_non_filterable_facets_no_filterable() {
async fn search_non_filterable_facets_multiple_facets() {
let server = Server::new_shared();
let index = server.unique_index();
let (response, _code) =
index.add_documents(json!([{"id": 1, "title": "Doggo", "genres": "Action"}]), None).await;
index.wait_task(response.uid()).await.succeeded();
let (response, _uid) =
index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await;
index.wait_task(response.uid()).await.succeeded();