Description
I am trying to create partial index through collection create index api. Below is sample code. The API works fine for single item. If there are multiple items, create index query is not generated. Instead SELECT statement generated and query execution is failing due to invalid index expression.
Couchbase lite net version: 3.2.2
var config = new ValueIndexConfiguration(itemsArray);
config.Where = where;
collection.CreateIndex(indexName, config);
Below partial index works fine:
CREATE INDEX partial_index ON "kv_.\A\L\E\R\T_\C\E\N\T\E\R" (fl_value(body, 'type')) WHERE fl_value(body, 'type') = 'job' AND fl_value(body, 'id') != ''
However, when I tried to create partial index with multiple expressions and where clause, I am seeing different query is generated.
Input:
ItemsArray = new string[]{"type", "priority"}
where = "type=\"job\" AND id != \"\""
Exceptions
error: 'Unable to execute action from message {"type":"Collection_CreateIndex","data":["input_bucket","_default","ALERT_CENTER","partial_index",{"type":"value","items":[["type","priority"]],"where":"type=\"job\" AND id != \"\""}]} due to uncaught exception',
message: 'CouchbaseLiteException (LiteCoreDomain / 23): Invalid N1QL in index expression "SELECT ( type,priority ) FROM _ WHERE ( type="job" AND id != "" )" near character 14.',
exceptionMessage: 'CouchbaseLiteException (LiteCoreDomain / 23): Invalid N1QL in index expression "SELECT ( type,priority ) FROM _ WHERE ( type="job" AND id != "" )" near character 14.',
stacktrace: 'Couchbase.Lite.CouchbaseLiteException: CouchbaseLiteException (LiteCoreDomain / 23): Invalid N1QL in index expression "SELECT ( type,priority ) FROM _ WHERE ( type="job" AND id != "" )" near character 14.\n' +
' at LiteCore.Interop.NativeHandler.ThrowOrHandle()\n' +
' at LiteCore.Interop.NativeHandler.Execute(C4TryLogicDelegate1 block)\n' +
' at LiteCore.LiteCoreBridge.Check(C4TryLogicDelegate1 block)\n' +
' at Couchbase.Lite.Collection.<>c__DisplayClass60_0.b__0()\n' +
' at Couchbase.Lite.Support.ThreadSafety.DoLocked(Action a)\n' +
' at Couchbase.Lite.Collection.CreateIndex(String name, IndexConfiguration indexConfig)\n' +
' at node_cblite.IonicCouchbaseLite.Collection_CreateIndex(String dbName, String scopeName, String collectionName, String indexName,