Kibana Regexp Filter Error Unexpected '.'

image

I am trying to create a filter than only shows page urls that have an extension. pagename.keyword:/.*.[^./]+/ works fine when I enter it into the search bar but I can't seem to find the right way to enter it as a filter in Query DSL using the regexp plugin. I'm getting an error that says "Unexpected '.'"
The reason I am using the .keyword is so that the whole url will be searchable instead of just specific terms.

Hey @caklier,

Try surrounding your regex in quotes:

{
   "query": {
      "regexp": {
          "pageurl.keyword": ".*......"
       }
   }
}

Putting quotes around the regex gives an error that says "bad string."

You may have to double-escape the expression. Try:

{
  "query": {
    "regexp": {
      "pageurl.keyword": ".*\\.[^\\.\\/]+"
    }
  }
}

Thank you, this worked. Could you please explain why there is a need to double escape the expression? I didn't read about this in any of the forums or documentation that I have come across so far so any clarification would be great.

At first I thought that your solution worked since the filter accepted this format. However, the filter doesn't work as I intended. If I click "exclude matches" on the filter, I still get some pageurls that SHOULD match the filter. For Example, /index.xhtml and /client/chat.php appear as not matching the original filter when they should as they are page urls with an extension. Could you help me fix my regex to include all page urls with extensions?

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