Fix getting script_exception when updating labels in highlights by checking null before updating

This commit is contained in:
Hongbo Wu 2022-08-19 14:36:58 +08:00
parent 3b6cf4d4c2
commit 0a75c52a8c

View file

@ -186,7 +186,7 @@ export const updateLabel = async (
ctx._source.labels.add(params.label);
ctx._source.updatedAt = params.updatedAt
}
if (ctx._source.highlights != null) {
if (ctx._source.highlights != null && ctx._source.highlights[0].labels != null) {
ctx._source.highlights[0].labels.removeIf(l -> l.id == params.label.id);
ctx._source.highlights[0].labels.add(params.label);
ctx._source.updatedAt = params.updatedAt