From 86270e687837fcafc2730b017c29a01d3d2e6613 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Thu, 11 Jan 2024 12:43:56 +0100 Subject: [PATCH] Transform fields contained into _format into strings --- meilisearch/src/search.rs | 7 +------ meilisearch/tests/settings/tokenizer_customization.rs | 10 +++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/meilisearch/src/search.rs b/meilisearch/src/search.rs index 7e783aa42..6893081d4 100644 --- a/meilisearch/src/search.rs +++ b/meilisearch/src/search.rs @@ -951,11 +951,6 @@ fn format_value<'a>( infos: &mut Vec, compute_matches: bool, ) -> Value { - // early skip recursive function if nothing needs to be changed. - if !format_options.as_ref().map_or(false, FormatOptions::should_format) && !compute_matches { - return value; - } - match value { Value::String(old_string) => { let mut matcher = builder.build(&old_string); @@ -1023,7 +1018,7 @@ fn format_value<'a>( let value = matcher.format(format_options); Value::String(value.into_owned()) } - None => Value::Number(number), + None => Value::String(s), } } value => value, diff --git a/meilisearch/tests/settings/tokenizer_customization.rs b/meilisearch/tests/settings/tokenizer_customization.rs index 7f205eb30..4602e31f7 100644 --- a/meilisearch/tests/settings/tokenizer_customization.rs +++ b/meilisearch/tests/settings/tokenizer_customization.rs @@ -94,7 +94,7 @@ async fn set_and_search() { "id": 1, "content": "Mac & cheese", "_formatted": { - "id": 1, + "id": "1", "content": "Mac & cheese" } }, @@ -102,7 +102,7 @@ async fn set_and_search() { "id": 3, "content": "Mac&sep&&sepcheese", "_formatted": { - "id": 3, + "id": "3", "content": "Mac&sep&&sepcheese" } } @@ -254,7 +254,7 @@ async fn advanced_synergies() { "id": 1, "content": "J.R.R. Tolkien", "_formatted": { - "id": 1, + "id": "1", "content": "J.R.R. Tolkien" } }, @@ -262,7 +262,7 @@ async fn advanced_synergies() { "id": 2, "content": "J. R. R. Tolkien", "_formatted": { - "id": 2, + "id": "2", "content": "J. R. R. Tolkien" } }, @@ -270,7 +270,7 @@ async fn advanced_synergies() { "id": 3, "content": "jrr Tolkien", "_formatted": { - "id": 3, + "id": "3", "content": "jrr Tolkien" } }