I am trying to find a way to get to Metrics.sortCount using .NET SDK.
http://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-rest-api/executen1ql.html
It doesn’t appear to be included in the SDK
Is there another way of getting it?
I am trying to find a way to get to Metrics.sortCount using .NET SDK.
http://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-rest-api/executen1ql.html
It doesn’t appear to be included in the SDK
Is there another way of getting it?
@enko -
There is no other way from the SDK atm, but I created a Jira ticket to add sortCount to the response in the next SDK release.
-Jeff
@jmorris thank you!
I’ve modified the driver temporarely until you release it.
Adding
[DataMember(Name = "sortCount", IsRequired=false)]
public uint SortCount { get; set; }
to Metrics.cs
@enko -
Awesome, I also just pushed a patch for review http://review.couchbase.org/#/c/59936/
Since you also patched it, you can always send a Pull Request and sign the CLA, then you’ll get credit as an official contributor. If you do, i’ll abandon my patch and take yours, if you add a unit test
Thanks!
-Jeff
@jmorris
Its ok, you got it! Thank you!
I think test is something like:
[Test]
public void Tests_SortCount_To_Return_With_GroupBy_and_Limit ()
{
using (var bucket = _cluster.OpenBucket())
{
((IQueryCacheInvalidator)bucket).InvalidateQueryCache();
var queryRequest = new QueryRequest()
.Statement("SELECT * FROM `beer-sample` ORDER BY meta(`beer-sample`).id LIMIT 0")
.AdHoc(false);
var result = bucket.Query<dynamic>(queryRequest);
Assert.IsTrue(result.Success, result.GetErrorsAsString());
Assert.Greater(result.Metrics.SortCount, 0);
}
}
I haven’t tested the test. Also not sure if IsRequired=false is needed, since I believe sortCount is omitted on non-grouped queries.