cloudant / python-cloudant

A Python library for Cloudant and CouchDB
Apache License 2.0
163 stars 55 forks source link

Couchdb 2.0 support #234

Closed chaitanya9186 closed 7 years ago

chaitanya9186 commented 8 years ago

Are there any plans of including couchdb 2.0 support.

rhyshort commented 8 years ago

Hi, CouchDB 2.0 should be supported, have you encountered any issues using the library with CouchDB 2.0?

chaitanya9186 commented 8 years ago

I wanna use Mango query. Is there any way I can use it.

rhyshort commented 8 years ago

Im pretty sure the query module should work with couch db 2 databases. See the doc for usage.

chaitanya9186 commented 8 years ago

Thanks for the link and quick reply. But the query module needs object instance of CloudantDatabase but not an instance of CouchDatabase.

I know in Couchdb 2.0 only special and json type mango indexes are supported but not text index. If we look at CloudantDatabase it has few unsupported by Couchdb 2.0 functionalities.

alfinkel commented 8 years ago

There's really nothing in the code that enforces that the database object used to construct a Query must be an instance of CloudantDatabase. Given that fact and the fact that this is Python and you can pretty much do whatever you want, you can certainly use Query functionality for a couchdb 2 instance if you wish to. Obviously you would need to steer clear of unsupported functionality like you mentioned but otherwise you should be fine.

I guess it would be good if we could add "official" support for couchdb 2 functionality though. @emlaver, is that something on the horizon?

chaitanya9186 commented 8 years ago

One more question: If I enable full text search in Couchdb 2.0 by following aritcle (https://cloudant.com/blog/enable-full-text-search-in-apache-couchdb), will I be able to use all the functionalities in Query module?

alfinkel commented 8 years ago

A few points first:

  1. This library is essentially just a set of CouchDB/Cloudant convenience API wrapped around Python requests.
  2. We do not currently support use with CouchDB 2.0 because adequate testing has just not been performed yet.

Keeping these two points in mind, this library does lend itself nicely to work with any CouchDB or Cloudant like HTTP request endpoint, mainly because of point (1). In other words if the end points in CouchDB and Cloudant match then there really is no reason why you shouldn't be able to use a CloudantDatabase object to interact with CouchDB instead of Cloudant. The only limitation there is that you can't use Admin Party mode when setting up a Cloudant client. CloudantDatabase just provides an additional set of convenience methods on top of what a CouchDatabase provides. So you should be able to construct a Query object by passing it a CouchDatabase object or a CloudantDatabase object that actually points to a CouchDB instance. The Query object doesn't care.

With all this said, the Query class is a wrapper for the _find endpoint (also see the CloudantDatabase get_query_result convenience method). The _search endpoint is handled by the CloudantDatabase get_search_result convenience method. Have a look at the documentation and see which convenience API is the right one for you.

emlaver commented 7 years ago

@chaitanya9186 I'm going to assume that Al's comment answered your question. I'm going to close this item, but if you have any more questions feel free to open up a new issue.