Regex query with ~ not working as expected

Hi,

I have a keyword field, and the value is email address like:
"21fd4444d3b0$28c042c9$ca123123$@abc.com"

when I do prefix query, I can get the result:

{
   "size": 10, 
   "query": {
     "prefix": {
       "myfield": {
        "value": "<21fd4444d3b0"
       }
     }
   }
 }

But when I do aggregation query, I can't get expected result:

{
  "size": 10, 
  "query": {
    "regexp": {
      "myfield": {
        "value": "\\<[0-9a-f]{4}**~(0[12])**[0-9a-f]{8}$[0-9af]{8}$[0-9a-f]{8}$@",
        "flags": "ALL"
      }
    }
  },
  "aggs": {
    "NAME": {
      "terms": {
        "field": "myfield",
        "size": 1000
      }
    }
  }
}

What I want to match is string that start with "<" and 4 hex chars, not followed by "01" or 02", and end with <8 hex><8 hex><8 hex>$, but I see that the some unexpected value returned, like:

"<000001d38fe4$20990770$61fb1231$@abc.com>"

The sixth and seventh chars are "01", this is not expected, because I use "~(0[12])" in the pattern, it should not matched.

Can anyone help to point out what is wrong with my query?

Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.