Hello All,
I am new in Couchbase and want to execute a Group By query on database. I have created an MVC application using C#.NET. Below is the code snippet:
> var config = new ClientConfiguration
> {
> Servers = new List<Uri>
> {
> new Uri("http://172.18.109.151:8091/pools"),
> new Uri("http://172.18.109.81:8091/pools"),
> new Uri("http://172.18.109.46:8091/pools"),
> new Uri("http://172.18.109.60:8091/pools"),
> new Uri("http://172.18.109.80:8091/pools")
> },
> UseSsl = false,
> DefaultOperationLifespan = 8100000,
> BucketConfigs = new Dictionary<string, BucketConfiguration>
> {
> {"NLA-testing", new BucketConfiguration
> {
> BucketName = "NLA-testing",
> UseSsl = false,
> Password = "",
> DefaultOperationLifespan = uint.MaxValue,
> PoolConfiguration = new PoolConfiguration
> {
> MaxSize = 10,
> MinSize = 5,
> SendTimeout = int.MaxValue, // this value wa
> }
> }}}
> };
> using (Cluster cls = new Cluster(config))
> {
> using (var buc = cls.OpenBucket("NLA-testing"))
> {
> string AggQuery = "SELECT Status.StatusCode, Status.Detail, Status.Meaning, COUNT(*) AS count FROM `NLA-testing` where (Status.StatusCode is not missing and Status.Detail is not missing and Status.Meaning is not missing)GROUP BY Status.StatusCode, Status.Detail, Status.Meaning";
> var AggResult = buc.Query<dynamic>(AggQuery);
> foreach (var row in AggResult.Rows)
> {
> if (row["StatusCode"] != null)
> datalist.Add(new StatusCount(Convert.ToInt32(row["StatusCode"]), Convert.ToInt32(row["count"]), row["Meaning"].ToString(), row["Detail"].ToString()));
> }
> }
> }
Below line creates error. “QueryResult.Status” gives “Fatal” and Exception gives “Unexpected character encountered while parsing value: <. Path , line 0, position 0.” message.
var AggResult = buc.Query(AggQuery);
More information is shown in below image:
I don’t know why it is happening. Is my configurations missing anything OR I am using wrong way to execute a query? If I run the code for multiple times then “QueryResult.Status” gives “Success” once in 10 runs.
Can anyone please help me to solve it out?
Thanks
Chetan