I have index with the following Map function (and no reduce function):
if (doc.someId && doc.anotherId)
{
emit([doc.someId, doc.anotherId], doc);
}
SomeId is int, and anotherId is string.
I'm using dotnet SDK 3.1 (https://www.nuget.org/packages/CouchbaseNetClient/3.1.1) to query the view like so:
var options = new ViewOptions();
object id = new object[] { 123, "777" };
options.Key(ids);
IViewResult<object, T> result;
result = await bucket.ViewQueryAsync<object, T>(designDocument, viewName, options);
var rows = await result.Rows.Select(r => r.Value).ToListAsync();
(designDocument and viewName are correct, connection established)
And I get the correct document successfully.
But when I want to query with multiple keys using the 'options.Keys()' function I get zero results (again both key surly existing in couchbase):
object[,] ids = new object[,] { { 123, "777" }, { 456, "888" } };
options.Key(ids);
IViewResult<object, T> result;
result = await bucket.ViewQueryAsync<object, T>(designDocument, viewName, options);
var rows = await result.Rows.Select(r => r.Value).ToListAsync();
Even if I try to use only one of the composite keys, but with array of arrays to 'Keys()' function not single array to 'Key()' function.
object[,] ids = new object[,] { { 123, "777" } };
options.Keys(ids);
Zero.
object[,] ids = new object[,] { { 456, "888" } };
options.Keys(ids);
Zero.
object id = new object[] { 123, "777" };
options.Key(id);
One result.
Why is this happening? Is this the correct format? It used to be the format on older version of dotnet SDK.
I also tried to use different Type at the ViewQueryAsync generic functin with no luck.
The documentation for this SDK is very poor and I couldn't find any example or explanation of the format needed.
question from:
https://stackoverflow.com/questions/65907252/why-querying-a-composite-key-view-with-multiple-keys-surely-existing-from-net