I have a simple document structure where a number of locations of different types are held (with GPS location and name).
An example:
{
"ispublic": true,
"key": "8641",
"name": "Grærup Langsø",
"points": [
{
"lat": 55.6529802987,
"lon": 8.1668484987
},
{
"lat": 55.6563176391,
"lon": 8.167440034
},
{
"lat": 55.6518253871,
"lon": 8.167535358
}
],
"type": "Lake"
}
If the user has not allowed the app to use the GPS then the user needs to search for the location (where he is fishing). So I have created this condition:
_condition = Expression.Property("name").Regex(Expression.String(search + ".*/i"))
.And(Expression.Property(TYPE).EqualTo(Expression.String(typeof(Lake).Name))
.Or(Expression.Property(TYPE).EqualTo(Expression.String(typeof(PutTakeLake).Name)))
.Or(Expression.Property(TYPE).EqualTo(Expression.String(typeof(CoastLocalArea).Name)))
.Or(Expression.Property(TYPE).EqualTo(Expression.String(typeof(SeaLocalArea).Name)))
.Or(Expression.Property(TYPE).EqualTo(Expression.String(typeof(Stream).Name)))
.Or(Expression.Property(TYPE).EqualTo(Expression.String(typeof(Country).Name))));
It includes all types of locations and tries to find the ones with a name that start with the letters entered by the user. But it does not match any names…
If I use
Expression.Property("name").Like(Expression.String(search + "%"))
Then it does match if I use the exact case “Gr” - but not “gr” (which it actually should according to the description and examples in: https://docs.couchbase.com/couchbase-lite/2.6/csharp.html#wildcard-match).
I have tried all sorts of different syntax attempts with the regex - but to no avail. I need to add the “/i” option to perform a case insensitive search. Attempts I have tried:
"gr/i"
"gr.*/i"
"/gr/i"
"gr\\/i"
"gr\\i"
And more (just pure wild shooting)…
Can anyone direct me to the right syntax