Fail on LIKE query while document contain "\n"

n1ql
query

#1

This is my document in DB
{
“msgCd”: “Test”,
“contents”: [
{
“langCd”: “en-US”,
“content”: “Introduction: \n “Triple Faces” is a kind of Chinese traditional leisure.”
},
{
“langCd”: “ja-JP”,
“content”: null
}
]
}

This is my query
SELECT msgCd, contents FROM mcms where any content in mcms.contents satisfies content.content LIKE “%Introduction%” END


How even it returns no record to me.
It only works if I change it from “%Introduction%” to “%Introduction%\n%”

How can I solve this problem ?


LIKE search with wildcard seems to be breaking on '-'
#2

Which version are you using? This was a known bug (https://issues.couchbase.com/browse/MB-19230) that AFAIK is fixed in 4.5.

For earlier versions, use the REGEX_LIKE() function instead.


#3

I am sorry that I forgot to mention which library I am using.
I am developing a C# program with the CouchbaseNetClient library version 2.3.5

From the information that https://issues.couchbase.com/browse/MB-19230 provided.
Seems it is not fixed in v4.5, and it is unresolved.

I tried the below REGEXP, and still no document that contains “\n” return, would you please help ?
any content in mcms.contents satisfies REGEXP_LIKE(content.content, ‘(.*)Introduction(.*)’ ) END


#4

Do you want a case sensitive match? Or case-insensitive?

For your example of a single string, it’s simplest to use:

REGEXP_CONTAINS(content.content,‘Introduction’)

Or, for case-insensitive:

REGEXP_CONTAINS(lower(content.content),‘introduction’)