fix searching for multiple labels (#444)

This commit is contained in:
Hongbo Wu
2022-04-19 12:13:47 +08:00
committed by GitHub
parent 1117a0c575
commit d7a2659fc4
2 changed files with 11 additions and 19 deletions

View File

@ -128,21 +128,17 @@ const appendIncludeLabelFilter = (
body: SearchBody, body: SearchBody,
filters: LabelFilter[] filters: LabelFilter[]
): void => { ): void => {
body.query.bool.filter.push({ filters.forEach((filter) => {
nested: { body.query.bool.filter.push({
path: 'labels', nested: {
query: { path: 'labels',
bool: { query: {
filter: filters.map((filter) => { terms: {
return { 'labels.name': filter.labels,
terms: { },
'labels.name': filter.labels,
},
}
}),
}, },
}, },
}, })
}) })
} }

View File

@ -32,12 +32,8 @@ export interface SearchBody {
nested: { nested: {
path: 'labels' path: 'labels'
query: { query: {
bool: { terms: {
filter: { 'labels.name': string[]
terms: {
'labels.name': string[]
}
}[]
} }
} }
} }