add search test on chinese scripts

This commit is contained in:
many 2020-12-17 15:13:58 +01:00
parent 748a8240dd
commit 0447594e02
No known key found for this signature in database
GPG Key ID: 2CEF23B75189EACA
3 changed files with 69 additions and 8 deletions

View File

@ -597,7 +597,7 @@ mod tests {
let mut m = Vec::new();
m.push(MatchPosition {
start: 510,
start: 529,
length: 9,
});
matches.insert("description".to_string(), m);
@ -613,6 +613,7 @@ mod tests {
assert_eq!(result, result_expected);
}
#[test]
fn highlight_longest_match() {
let data = r#"{

View File

@ -1590,18 +1590,18 @@
"tags": []
},
{
"id": 76,
"id": 77,
"isActive": false,
"balance": "$1,274.29",
"picture": "http://placehold.it/32x32",
"age": 25,
"color": "Green",
"name": "Clarice Gardner",
"gender": "female",
"email": "claricegardner@chorizon.com",
"color": "Red",
"name": "孙武",
"gender": "male",
"email": "SunTzu@chorizon.com",
"phone": "+1 (810) 407-3258",
"address": "894 Brooklyn Road, Utting, New Hampshire, 6404",
"about": "Elit occaecat aute ea adipisicing mollit cupidatat aliquip excepteur veniam minim. Sunt quis dolore in commodo aute esse quis. Lorem in cillum commodo eu anim commodo mollit. Adipisicing enim sunt adipisicing cupidatat adipisicing eiusmod eu do sit nisi.\r\n",
"address": "吴国",
"about": "孫武前544年前470年或前496年字長卿春秋時期齊國人著名軍事家、政治家兵家代表人物。兵書《孙子兵法》的作者後人尊稱為孫子、兵聖、東方兵聖山東、蘇州等地尚有祀奉孫武的廟宇兵聖廟。其族人为乐安孙氏始祖次子孙明为富春孙氏始祖。\r\n",
"registered": "2014-10-20T10:13:32 -02:00",
"latitude": 17.11935,
"longitude": 65.38197,

View File

@ -358,6 +358,66 @@ async fn search_with_attribute_to_highlight_wildcard() {
});
}
#[actix_rt::test]
async fn search_with_attribute_to_highlight_wildcard_chinese() {
let mut server = common::Server::test_server().await;
let query = json!({
"q": "子孙",
"limit": 1,
"attributesToHighlight": ["*"]
});
let expected = json!([
{
"id": 77,
"isActive": false,
"balance": "$1,274.29",
"picture": "http://placehold.it/32x32",
"age": 25,
"color": "Red",
"name": "孙武",
"gender": "male",
"email": "SunTzu@chorizon.com",
"phone": "+1 (810) 407-3258",
"address": "吴国",
"about": "孫武前544年前470年或前496年字長卿春秋時期齊國人著名軍事家、政治家兵家代表人物。兵書《孙子兵法》的作者後人尊稱為孫子、兵聖、東方兵聖山東、蘇州等地尚有祀奉孫武的廟宇兵聖廟。其族人为乐安孙氏始祖次子孙明为富春孙氏始祖。\r\n",
"registered": "2014-10-20T10:13:32 -02:00",
"latitude": 17.11935,
"longitude": 65.38197,
"tags": [
"new issue",
"wontfix"
],
"_formatted": {
"id": 77,
"isActive": false,
"balance": "$1,274.29",
"picture": "http://placehold.it/32x32",
"age": 25,
"color": "Red",
"name": "<em>孙武</em>",
"gender": "male",
"email": "SunTzu@chorizon.com",
"phone": "+1 (810) 407-3258",
"address": "吴国",
"about": "<em>孫武</em>前544年前470年或前496年字長卿春秋時期齊國人著名軍事家、政治家兵家代表人物。兵書《<em>孙子</em>兵法》的作者,後人尊稱為<em>孫子</em>、兵聖、東方兵聖,山東、蘇州等地尚有祀奉<em>孫武</em>的廟宇兵聖廟。其族人为乐安<em>孙</em>氏始祖,次<em>子孙</em>明为富春<em>孙</em>氏始祖。\r\n",
"registered": "2014-10-20T10:13:32 -02:00",
"latitude": 17.11935,
"longitude": 65.38197,
"tags": [
"new issue",
"wontfix"
]
}
}
]);
test_post_get_search!(server, query, |response, _status_code| {
assert_json_eq!(expected.clone(), response["hits"].clone(), ordered: false);
});
}
#[actix_rt::test]
async fn search_with_attribute_to_highlight_1() {
let mut server = common::Server::test_server().await;