Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Couchbase .Net Client Query Generation

2 replies [Last post]
  • Login or register to post comments
Thu, 12/22/2011 - 12:38
arishlabroo
Offline
Joined: 12/22/2011
Groups: None

Hello,

I have a question about the http request that couchbase .net client makes to satisfy my query.

I have one bucket with one view on the couchbase server. The map function on the view is :

    function (doc) {
      if(doc.type=='Article'){
        emit(doc._id, doc);}
    }

In my test, i am using the couchbase client like this:

    public void Test_get_by_title()
        {
            var client = new CouchbaseClient();
            var query = client.GetView("content", "articles")
                              .Select(a => (string) a.GetItem()) 
                              .Select(x => JsonUtility.Deserialize<Article>(x))
                              .Where(art => art.Title == "clp test");
 
            foreach (var article in query)
            {
                Console.WriteLine(article.Id);
            }
        }

JsonUtility.Deserialize is a static method which uses NewtonsoftJson.Net for deserialization.

Now this does what I want, but not in the way I thought.

I was under the assumption that the http request to the couchbase server would include the condition as a query string. And the http response will bring back only the Article JSON which meet this condition.

But the request that is being sent is http://11.1.1.111:8088/bucket_name/_design/dev_content/_view/view_name without any query string and this brings back everything from couchbase and then deserializes all the rows and then filters the list of Articles.

As you can see this behavior is not acceptable when we have large data.

Please help me in the right direction, What am I doing wrong?

I am using Couchbase .Net Client 0.9.2 and the server is version 2.0.0 community edition (build-388-gf35126e).

All help is appreciated.

Top
  • Login or register to post comments
Thu, 12/22/2011 - 18:45
thoreaupoop
Offline
Joined: 12/22/2011
Groups: None

I noticed the same thing and it makes the performance horrible...there is no way this could be used in a production environment. The original Hammock API for CouchDb had the Linq code emitting the view and then executed the proper request on that view:

var r = new Repository(s);
var z = r.Where(x => x.Name).Eq("PS3")
.And(x => x.Price).Le(400)
.List();

Hammock will update CouchDB's design document with a new view:

{
"_id": "_design/product",
"language": "javascript",
"views": {
"by-name-price": {
"map": "
function(doc) {
if (doc._id.indexOf('product-') === 0) {
emit([doc.Name, doc.Price], null);
}
}",
"reduce": null
}
}
}

And then execute a request against that view, using the parameters specified:

GET /sample-db/_design/product/_view/by-name-cost?startkey=["PS3",null]&endkey=["PS3",400]

http://code.google.com/p/relax-net/

IMO, the .NET Couchbase client is completely broken...

Top
  • Login or register to post comments
Thu, 01/05/2012 - 18:36
john
Offline
Joined: 01/05/2012
Groups: None

Please see http://www.couchbase.org/forums/thread/couchbase-net-client-library-20-p...

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker