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

Feature Request: Console to support View Lookup via key (in addition to document ID)

9 replies [Last post]
  • Login or register to post comments
Wed, 09/07/2011 - 09:37
adamdavies
Offline
Joined: 06/02/2011
Groups: None

Is the the right place to post a feature request?

Anyway, I have a map function which emits a key which is composed of two different fields, but to test it I can not put the compound key in the "Lookup Id" field because this only works against document IDs.

It would be great if we can also have a field that allows lookup via the emitted key.

Just to give some backgroud:

We have docuements relating to Invoices. Each invoice is a json document, has a unique id (_id) and sellerID and buyerID fields.

So when we want to find all the invoices issued by seller A against seller B, we use a map funtion with a key made of of sellerA's Id and sellerB's Id. The Invoice document is the value.

Thanks
Adam

Top
  • Login or register to post comments
Thu, 09/08/2011 - 05:46
jan
Offline
Joined: 02/15/2011
Groups: None

Hi Adam,

if you go into the view editor, under run results, there's a triangle that reveals a pop-up box that allows you to specify all sorts of query parameters, including "keys".

For the record, the "official" place to report feature requests is our issue tracker http://www.couchbase.org/issues/ but don't worry too much if you report it here :)

Cheers
Jan
--

Top
  • Login or register to post comments
Mon, 09/12/2011 - 02:00
adamdavies
Offline
Joined: 06/02/2011
Groups: None

Thanks Jan, but...

When I put a value into the "keys" I get:

{"error":"bad_request","reason":"invalid UTF-8 JSON: {{case_clause,<<\"CMP_00239787\">>},\"CMP_00239787\"}"}  

 

URL I have is:

http://192.168.2.71:5984/default/_design/dev_prototype/_view/getAllCompanies?keys=CMP_00239787&connection_timeout=60000&limit=10&skip=0

 

Just to be clear, I took the key value (CMP_00239787) from the View button without any restriction.

Tried on a few other view methods and same result.

Using the API:

View view = couchbaseClient.getView("prototype", "getAllCompanies");
Query query = new Query();
query.setKey("CMP_00239787");
...

and everything works fine.

 

Thanks Adam

Top
  • Login or register to post comments
Mon, 09/12/2011 - 06:46
sveinhelge
Offline
Joined: 09/03/2011
Groups: None

Are you sending the keys as an array? (It expects an array)

Have you tried this: keys = ["CMP_00239787"]
(Remember to have the double quotes)

Top
  • Login or register to post comments
Mon, 09/12/2011 - 08:07
BigBlueHat
Offline
Joined: 01/28/2011
Groups: None

sveinhelge's correct. It does need to be formatted as an Array.

I've made a ticket for improving the User Experience of that field or (at least) adding a note about how it should be formatted:
http://www.couchbase.org/issues/browse/MB-4277

Feel free to vote for it. :)

Thanks,
Benjamin

Top
  • Login or register to post comments
Wed, 09/14/2011 - 04:17
adamdavies
Offline
Joined: 06/02/2011
Groups: None

OK, so here is the work-around (using the URL)

URL:

http://192.168.2.71:5984/default/_design/dev_prototype/_view/getAllCompanies?keys="CMP_00239787"

Result:

{"error":"bad_request","reason":"`keys` parameter is not an array."}

However using:
URL:

http://192.168.2.71:5984/default/_design/dev_prototype/_view/getAllCompanies?key="CMP_00239787"

works fine. Note key rather than keys. And you do have to use the quotes.

Thanks
Adam

Top
  • Login or register to post comments
Wed, 09/14/2011 - 10:23
sveinhelge
Offline
Joined: 09/03/2011
Groups: None

I don't see that url as a work-around. If you use the user interface and set keys to ["CMP_00239787"] it will work. (Remember to have the double quotes and square brackets)

Also remember when using the URL http://192.168.2.71:5984/default/_design/dev_prototype/_view/getAllCompanies?key="CMP_00239787" you will only hit that one node running the CouchDB server.Since Couchbase Server 2.0 is a cluster solution that does not make so much sense. The url you are refering to using key="CMP_00239787" is how CouchDB works out of the box.

Top
  • Login or register to post comments
Wed, 09/14/2011 - 10:32
BigBlueHat
Offline
Joined: 01/28/2011
Groups: None

Just an FYI, there's a commit en route to get "key" added as an option:
http://review.couchbase.org/#change,9524

Top
  • Login or register to post comments
Thu, 09/15/2011 - 06:56
adamdavies
Offline
Joined: 06/02/2011
Groups: None

Thanks, but could you clarify what you mean by only hitting a single node? What URL should be used to hit the full cluster? This URL was taken from the Filter Results link on the View page of Couchebase console.

Thanks
Adam

Top
  • Login or register to post comments
Thu, 09/15/2011 - 13:23
sveinhelge
Offline
Joined: 09/03/2011
Groups: None

This URL will get data from one node
http://192.168.2.71:5984/default/_design/dev_prototype/_view/getAllCompanies?key="CMP_00239787"

This URL will get data from the cluster (all nodes holding data for selected bucket)
http://192.168.2.71:5984/default/_design/dev_prototype/_view/getAllCompanies?full_set=true&key="CMP_00239787"
(only difference is the parameter full_set=true)
(If you click the button Full Cluster Data Set an option is added to the URL. full_set=true. When full_set=true is set it will return data from the cluster.)

Now we get data from the cluster, so what is the problem? Well the problem is that you are hitting a specific server even if you get data from the cluster. If you start using that URL in your application it will work as long as the node you are hitting is up and running. If that node fails you will get nothing. Since this is a cluster solution that is not what we normally wants. If you look at the configuration of the different client libraries you will see that they have the possibility to configure several nodes.

This is from the Web.config/App.config (.NET Client Library):

As you see, you can in the server section add all server in the cluster. You can also configure a connection pool++. You may also notice that we are using port 8091. (This is the address to the REST API) Port 5984 is normally blocked for clients. Except for the clients you want to run the web administration tool from.

Read about Moxi (part of Couchbase) for more details.

I not an expert in this area so there are many other people who can more about this and can explain this far better than I can.

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