The result is the same when I modified the query




I have a problem when I try to retrieve some documents, but when I restart the couchbase service the result is correct.

I am using C#, CouchBase 4.0 Beta, BucketType “CouchBase”

My query is very simple:

var result = bucket.Query(
new QueryRequest(“SELECT q.* FROM MasterQrs as q”));

I want to know if it is a issue or some trouble with the configuration of bucket.



Hey @Antx2207,

Can I get a bit more information:

  1. What version of Couchbase Server are you using? The build number too if possible.
  2. What are your actual results, and what are your expected results? (What happens when it doesn’t work and what happens when it does)

Let’s start there :smile:



Hi nraboy,

Im using “You are running version 4.0.0-2213 DEV Edition (build-2213).”

Let me show you this:

var result = bucket.Query<dynamic>(
                    new QueryRequest("SELECT q.* FROM MasterQrs as q WHERE q.type = 'IwpCumulative' AND q.period = 5  AND q.sumActual < 400 AND q.category = 'Qty'"));

and the other hand:

var iwps = bucket.Get<IWPCumulative>(data.Value.iwp);

                var result = from ite in iwps.Values
                                  where ite.Value.Type == "IwpCumulative" && ite.Value.Period == 5 && ite.Value.SumActual < 400 && ite.Value.Category = "Qty"
                                  select ite.Value;



Hey @Antx2207,

Just so I’m clear, the first snippet you pasted works, but the second does not?



The first with N1QL return some documents but when I using a lot and modified the query resquest always return the same result, when I restart the couchbase service and execute I get the correct result.


Hey @Antx2207,

When you try to return many documents and it fails, how many are you trying to return? Can you try these same queries using the Couchbase Query (CBQ) Client and see if your results are correct with it?


C:/Program Files/Couchbase/Server/bin/cbq.exe



Trying to narrow it down to see if maybe your query is at fault, the bucket, or the C# SDK.



Hay @nraboy,

I did can reproduce the error case.

I need evaluate the best way to get multiple rows and use agregation functions. My test cases are:

  1. Create N documents.
  2. Retrieve documents and aggregation operation with Linq and N1QL so result is correct with 100 documents.
  3. I Flush the bucket (I dont know if it is good practice), and I fill again the bucket but with more documents (101103 documents).
  4. When I tried use N1QL the result is wrong and I tried too using cbq and the result is wrong too.
  5. I restart couchbase service and I made the query and result is correct.

This way the problem is the couchbase version?



Hey @Antx2207,

I am wondering if indexing has completed before you try to run your query. While Couchbase can certainly handle 100,000 documents with no issues, it still is no small number.

To help with the accuracy of this theory, can you try filling with a smaller data set or waiting a bit before querying after a flush?



Hey @nraboy,

Yes, index had complete before run my query.

Could you reproduce this scenario?




Can you please use cbq and post the results of both the queries (the original and modified one) along with the queries. Also could you specify which one is correct and which isn’t ?
We can take a look at the issue once we have these details.