We have a similar mapping to this one:
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"tags": {
"type": "keyword"
}
}
}
}
}
And documents like this... 1)TERM1-TERM2-TERM4-TERM3 2)TERM1-TERM2-TERM5-TERM3
Using an expression like this
GET /my_index/_doc/_search
{
"query": {
"regexp": {
"tag": "TERM1.*TERM3"
}
}
}
I am able to match with the documents since I am matching the whole keyword with the regex. But the matching that I really need is something like TERM2-*-TERM3, where * matches only with a WORD, and not with many words. Is it possible to achieve what I like? Another expression that I would like to write is TERM1---TERM3 Matching both documents too.
Thanks
TERM1-(.*[^A-Za-z0-9_])?TERM2([^A-Za-z0-9_].*)?-TERM3
. The second one should beTERM1-[^-]*-[^-]*-TERM3
– Wiktor Stribiżew