Refactor exclude labels query

This commit is contained in:
Hongbo Wu 2023-02-17 12:13:20 +08:00
parent 9584267c48
commit 153ca6995b
2 changed files with 7 additions and 8 deletions

View file

@ -114,16 +114,15 @@ const appendExcludeLabelFilter = (
body: SearchBody,
filters: LabelFilter[]
): void => {
const labels = filters.map((filter) => filter.labels).flat()
body.query.bool.must_not.push({
nested: {
path: 'labels',
query: filters.map((filter) => {
return {
terms: {
'labels.name': filter.labels,
},
}
}),
query: {
terms: {
'labels.name': labels,
},
},
},
})
}

View file

@ -103,7 +103,7 @@ export interface SearchBody {
terms: {
'labels.name': string[]
}
}[]
}
}
}
)[]