mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 03:47:02 +02:00
Merge pull request #5494 from meilisearch/deactivate-numbers-in-typos
Deactivate numbers in typos
This commit is contained in:
commit
96bc519f9e
19 changed files with 296 additions and 35 deletions
|
@ -87,7 +87,8 @@ async fn import_dump_v1_movie_raw() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -260,7 +261,8 @@ async fn import_dump_v1_movie_with_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -432,7 +434,8 @@ async fn import_dump_v1_rubygems_with_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -590,7 +593,8 @@ async fn import_dump_v2_movie_raw() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -760,7 +764,8 @@ async fn import_dump_v2_movie_with_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -929,7 +934,8 @@ async fn import_dump_v2_rubygems_with_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -1087,7 +1093,8 @@ async fn import_dump_v3_movie_raw() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -1257,7 +1264,8 @@ async fn import_dump_v3_movie_with_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -1426,7 +1434,8 @@ async fn import_dump_v3_rubygems_with_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -1584,7 +1593,8 @@ async fn import_dump_v4_movie_raw() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -1754,7 +1764,8 @@ async fn import_dump_v4_movie_with_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -1923,7 +1934,8 @@ async fn import_dump_v4_rubygems_with_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -2212,7 +2224,8 @@ async fn import_dump_v6_containing_experimental_features() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -2444,7 +2457,8 @@ async fn generate_and_import_dump_containing_vectors() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
|
|
@ -1976,3 +1976,93 @@ async fn change_facet_casing() {
|
|||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_exact_typos_terms() {
|
||||
let documents = json!([
|
||||
{
|
||||
"id": 0,
|
||||
"title": "The zeroth document 1298484",
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"title": "The first document 234342",
|
||||
"nested": {
|
||||
"object": "field 22231",
|
||||
"machin": "bidule 23443.32111",
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "The second document 3398499",
|
||||
"nested": [
|
||||
"array",
|
||||
{
|
||||
"object": "field 23245121,23223",
|
||||
},
|
||||
{
|
||||
"prout": "truc 123980612321",
|
||||
"machin": "lol 12345645333447879",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "The third document 12333",
|
||||
"nested": "I lied 98878",
|
||||
},
|
||||
]);
|
||||
|
||||
// Test prefix search
|
||||
test_settings_documents_indexing_swapping_and_search(
|
||||
&documents,
|
||||
&json!({
|
||||
"searchableAttributes": ["title", "nested.object", "nested.machin"],
|
||||
"typoTolerance": {
|
||||
"enabled": true,
|
||||
"disableOnNumbers": true
|
||||
}
|
||||
}),
|
||||
&json!({"q": "12345"}),
|
||||
|response, code| {
|
||||
assert_eq!(code, 200, "{}", response);
|
||||
snapshot!(json_string!(response["hits"]), @r###"
|
||||
[
|
||||
{
|
||||
"id": 2,
|
||||
"title": "The second document 3398499",
|
||||
"nested": [
|
||||
"array",
|
||||
{
|
||||
"object": "field 23245121,23223"
|
||||
},
|
||||
{
|
||||
"prout": "truc 123980612321",
|
||||
"machin": "lol 12345645333447879"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"###);
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
// Test typo search
|
||||
test_settings_documents_indexing_swapping_and_search(
|
||||
&documents,
|
||||
&json!({
|
||||
"searchableAttributes": ["title", "nested.object", "nested.machin"],
|
||||
"typoTolerance": {
|
||||
"enabled": true,
|
||||
"disableOnNumbers": true
|
||||
}
|
||||
}),
|
||||
&json!({"q": "123457"}),
|
||||
|response, code| {
|
||||
assert_eq!(code, 200, "{}", response);
|
||||
snapshot!(json_string!(response["hits"]), @r###"[]"###);
|
||||
},
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ async fn settings_bad_typo_tolerance() {
|
|||
snapshot!(code, @"400 Bad Request");
|
||||
snapshot!(json_string!(response), @r###"
|
||||
{
|
||||
"message": "Unknown field `typoTolerance`: expected one of `enabled`, `minWordSizeForTypos`, `disableOnWords`, `disableOnAttributes`",
|
||||
"message": "Unknown field `typoTolerance`: expected one of `enabled`, `minWordSizeForTypos`, `disableOnWords`, `disableOnAttributes`, `disableOnNumbers`",
|
||||
"code": "invalid_settings_typo_tolerance",
|
||||
"type": "invalid_request",
|
||||
"link": "https://docs.meilisearch.com/errors#invalid_settings_typo_tolerance"
|
||||
|
|
|
@ -179,7 +179,7 @@ test_setting_routes!(
|
|||
{
|
||||
setting: typo_tolerance,
|
||||
update_verb: patch,
|
||||
default_value: {"enabled": true, "minWordSizeForTypos": {"oneTypo": 5, "twoTypos": 9}, "disableOnWords": [], "disableOnAttributes": []}
|
||||
default_value: {"enabled": true, "minWordSizeForTypos": {"oneTypo": 5, "twoTypos": 9}, "disableOnWords": [], "disableOnAttributes": [], "disableOnNumbers": false}
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -276,7 +276,7 @@ async fn secrets_are_hidden_in_settings() {
|
|||
|
||||
let (response, code) = index.settings().await;
|
||||
meili_snap::snapshot!(code, @"200 OK");
|
||||
meili_snap::snapshot!(meili_snap::json_string!(response), @r#"
|
||||
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||
{
|
||||
"displayedAttributes": [
|
||||
"*"
|
||||
|
@ -308,7 +308,8 @@ async fn secrets_are_hidden_in_settings() {
|
|||
"twoTypos": 9
|
||||
},
|
||||
"disableOnWords": [],
|
||||
"disableOnAttributes": []
|
||||
"disableOnAttributes": [],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 100,
|
||||
|
@ -337,7 +338,7 @@ async fn secrets_are_hidden_in_settings() {
|
|||
"facetSearch": true,
|
||||
"prefixSearch": "indexingTime"
|
||||
}
|
||||
"#);
|
||||
"###);
|
||||
|
||||
let (response, code) = server.get_task(settings_update_uid).await;
|
||||
meili_snap::snapshot!(code, @"200 OK");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: crates/meilisearch/tests/upgrade/v1_12/v1_12_0.rs
|
||||
snapshot_kind: text
|
||||
---
|
||||
{
|
||||
"displayedAttributes": [
|
||||
|
@ -49,7 +48,8 @@ snapshot_kind: text
|
|||
],
|
||||
"disableOnAttributes": [
|
||||
"surname"
|
||||
]
|
||||
],
|
||||
"disableOnNumbers": false
|
||||
},
|
||||
"faceting": {
|
||||
"maxValuesPerFacet": 99,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue