Full text search by regex key


#1

Hi, I am trying to create a full text search index based on a regex on a key. I can understand from documentation how the regex expression works.
Our Ids are like this:
event:email:action:input:61ae2ecf-ec6c-4eca-ac56-ac6fd9f38ec7:engine-facing-node-2
I want to get all events that start with “event:email:action:input:” and assign it to the mapping object that we created “email”

What should go on the “Doc ID with regex:” ?
event:(.):action:input:.

So it maps to email using the () ?

Thanks


#2

Unfortunately when we built this capability, we opted for a simple approach, so we do not support capture groups. The portion of the key that matches the entire regular expression will be used for the resulting type. This makes it hard to extract portions of the key, particularly in the middle or end and not include the surrounding context in the type name.

One option, if all documents of type email start with event is to use the longer pattern ‘event:email’ as your pattern (and that then is the result type).

Another option is to use a pattern like

\bemail\b

The \b will match word boundaries (which : satisfies). This is more brittle, and can match email showing up in other parts of the key if that is possible (you would have to examine your key naming convention closely).


#3

That will be what i need to match, so the regex will be “event:email:action:input” and the object mapping that i need should be called also “event:email:action:input”, would that be correct?


#4

Using that as the regex will work, but will only match documents with that exact text. I’d suggest adding the ^ character at the start to ensure it is anchored to the start of the key. And type name used in the FTS mapping will also need to be the full “event:email:action:input”.


#5

Will try it out, thanks for your help.