cloudant / java-cloudant

A Java client for Cloudant
Apache License 2.0
79 stars 68 forks source link

Allow to query view with multiple key #42

Closed sbrunot closed 9 years ago

sbrunot commented 9 years ago

It seems that a view can only be queried with a single key, using the key(Object...) method of com.cloudant.client.api.View. In the meantime, cloudant allows querying using multiple keys (using query parameter keys=...), so it would be helpful to have a method that allow querying using multiple keys (for example a method keys(Object[]) on the com.cloudant.client.api.View class).

mariobriggs commented 9 years ago

See the Fetch all/multiple documents section of the Readme. It has an example using a list

sbrunot commented 9 years ago

Unfortunately, this example works only when querying the "_all_docs" view... I would like to be able to query any view, using simple or complex keys. I managed to do so by adding keys(Object[]) method to the com.cloudant.client.api.View and org.lightcouch.View method, and was wondering if it could be added to the api ?

mariobriggs commented 9 years ago

See byComplexKey() in viewsTest for an example of complex keys. There is a start/end e.g. in byStartAndEndKey() too. Over and above that, we welcome Pull requests

sbrunot commented 9 years ago

As you can seen the byComplexKey only query with one single complex key. I'd be happy to submit a pull request: do you have a documented procedure on how to create a test account on cloudant to run the project unit tests ? I've tried to run the unit tests using a cloudant database created on Bluemix but didn't succeed...

mariobriggs commented 9 years ago

See #29 for another examples of complex keys with start and end. Maybe if show the http request code, i can comment better. What error did u hit with a bluemix created cloudant for running the tests, there is no difference between one created directly from cloudant.com vs bluemix

sbrunot commented 9 years ago

I've been able to run the tests on my database, so I've created a pull request for you to review: https://github.com/cloudant/java-cloudant/pull/43

mariobriggs commented 9 years ago

fixed via commit 4773586

AparnaPillai46 commented 7 years ago

I want to parse my key into objects from the view. My key is something like this ... Is this possible ?

"key":{
"pId":"xxxx", "pType":"yyy", "pName":"xxx", "spT":"qqqq", "ind":"Y", "order":1, "templ":"aaaaa", "p":[ "aaaaa"] }