ropensci / sofa

Easy R interface to CouchDB
https://docs.ropensci.org/sofa/
33 stars 17 forks source link

design_search needs POST support to use key feature #56

Closed davbwhit closed 7 years ago

davbwhit commented 7 years ago

Get "Error: (400) - invalid UTF-8 JSON" when trying to specify a key to retrieve from a view.

Couch documentation 10.5.4 indicates: Unlike GET /{db}/_design/{ddoc}/_view/{view} for accessing views, the POST method supports the specification of explicit keys to be retrieved from the view results. The remainder of the POST view functionality is identical to the GET /{db}/_design/{ddoc}/_view/{view} API.

Any chance of getting an updated design_search with POST support to handle the super-set of features?

sckott commented 7 years ago

hi @davbwhit thanks for opening the issue

I'll have a look, perhaps may be a quick fix

sckott commented 7 years ago

@davbwhit can you try again after reinstalling like devtools::install_github("ropensci/sofa")

can do POST now if you use body parameter, and also design_search_many function added for sending many queries at once.

ghost commented 6 years ago

How do you specify a key? I have a composite key on two fields , on is a id field (string) and other is a timstamp that is an integer. Trying variations of the following and getting various errors.

design_search(connection, 'dbname', 'designname', 'viewname', key = list('09f3eef7b47164b0ed9f1b7775f3e5be', 1511170394))
Error in lapply(x, f) : attempt to apply non-function
sckott commented 6 years ago

@tumulurig3 try giving that list to the body parameter, like body = list(keys = c('09f3eef7b47164b0ed9f1b7775f3e5be', 1511170394))

ghost commented 6 years ago

Had some issue making the above work, but re-starting RStudio and re-invoking the library made the call work with above format. However, it returns no documents, even though I know that key exists in the DB. Perhaps some other issue. Thank you!