Allow wildcards in label: filter

This commit is contained in:
Hongbo Wu 2023-04-21 17:10:46 +08:00
parent 2fb18f396b
commit b2c115f9d9

View file

@ -119,8 +119,25 @@ const appendIncludeLabelFilter = (
builder = builder.query('nested', {
path: 'labels',
query: {
terms: {
'labels.name': filter.labels,
bool: {
should: filter.labels.map((label) => {
if (label.includes('*')) {
// Wildcard query
return {
wildcard: {
'labels.name': {
value: label,
},
},
}
}
return {
term: {
'labels.name': label,
},
}
}),
minimum_should_match: 1,
},
},
})