mirror of
https://github.com/typesense/typesense.git
synced 2025-05-21 06:02:26 +08:00
Add array index check for highlight of string array.
This commit is contained in:
parent
d4bd6e67e5
commit
67e67b7d06
@ -1659,8 +1659,25 @@ void Collection::highlight_result(const field &search_field,
|
||||
/*LOG(INFO) << "field: " << document[search_field.name] << ", id: " << field_order_kv->key
|
||||
<< ", index: " << match_index.index;*/
|
||||
|
||||
std::string text = (search_field.type == field_types::STRING) ? document[search_field.name] :
|
||||
document[search_field.name][match_index.index];
|
||||
std::string text;
|
||||
|
||||
if(search_field.type == field_types::STRING) {
|
||||
text = document[search_field.name];
|
||||
} else {
|
||||
if(!document[search_field.name].is_array()) {
|
||||
LOG(ERROR) << "Skipping highlight of field " << search_field.name << " because it is not an array.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if(match_index.index >= document[search_field.name].size()) {
|
||||
LOG(ERROR) << "Skipping highlight of field " << search_field.name << " because match index "
|
||||
<< match_index.index << " exceeds array size of " << document[search_field.name].size();
|
||||
continue;
|
||||
}
|
||||
|
||||
text = document[search_field.name][match_index.index];
|
||||
}
|
||||
|
||||
Tokenizer tokenizer(text, true, false, search_field.locale);
|
||||
|
||||
if(search_field.locale == "ko") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user