Fix not setting labels to the correct highlight in a page

This commit is contained in:
Hongbo Wu 2022-12-29 21:34:45 +08:00
parent 434aaf98b0
commit 264ebef46e
2 changed files with 3 additions and 2 deletions

View file

@ -70,7 +70,7 @@ export const getHighlightById = async (
nested: {
path: 'highlights',
query: {
match: {
term: {
'highlights.id': id,
},
},

View file

@ -260,10 +260,11 @@ export const setLabelsForHighlight = async (
index: INDEX_ALIAS,
body: {
script: {
source: `ctx._source.highlights[0].labels = params.labels;
source: `ctx._source.highlights.stream().filter(h -> params.highlightId.equals(h.id)).findAny().orElse(null).labels = params.labels;
ctx._source.updatedAt = params.updatedAt`,
lang: 'painless',
params: {
highlightId,
labels: labels,
updatedAt: new Date(),
},