Search code examples
regexfull-text-searchcouchbasebleve

Custom character filter in analyzer not working


i am using regexp character filter in couchbase for my analyzer. desirable result following

phuong 1 -> phuong_1
phuong  12 -> phuong_12

Configuration character filter in Couchbase Web Console following

Regular expression : ([a-z])\s+(\\d)
Replacement: $1_
  • Result of above configuration is produce term [phuong,1, 12 ]
  • Desirable result is [phuong_1 , phuong_12]
  • I have aligned this code many times But it still not working correct
  • Can you help me this problem ?

Solution

  • Couchbase's Full text search is implemented in golang. Here's a playground illustration of how your regular expression works ..

    https://play.golang.org/p/Jray7DTYZam

    As you can see in the illustration above, $1x is equivalent to ${1x}, not ${1}x. So your replacement needs to be updated to ${1}_.

    Now this said, we have a limitation that variables ($1, ${2} etc.) aren't supported at the moment. I've created an internal ticket to extend support for this.