Reputation: 408
I would like to know how can I use regex in a script. Example:
"aggs": {
"inventary": {
"sum": {
"script": "(doc['action'].value == /^request/) ? 1 : 0"
}
}
}
So I would like to match every action
who matches with request*
It is possible?
Thank you
Upvotes: 1
Views: 560
Reputation: 217564
Yes, you simply need to use ==~
instead of ==
"aggs": {
"inventary": {
"sum": {
"script": "(doc.action.value ==~ /^request/) ? 1 : 0"
}
}
}
Upvotes: 2