Closed ghost closed 4 years ago
thanks @tumulurig3
can you elaborate on what you mean by composite key?
Meaning the key is made up of two different fields in the document. Some field called 'some_id' that is a document ID of some other document, and a timestamp field that is integer in seconds since epoch. Both are combined to be the key on the view.
apologies, but i'm not familiar with composite/complex keys. any couchdb docs on that?
Here is the cloudant screenshot with one of the documents as example. You see id, key and value columns. Value is the actual document. Key is a combination of 'building_id' and 'timestamp' fields. The id is the cloudant ID of the document that is indexed based on building_id/timestamp combination.
Ignore my terminology about 'composite.' All I mean is that the index on this view is made up of two fields within the document.
thanks for that.
@ghost sorry for the very long delay.
first, those parameters (startkey, endkey) need to be passed to either params
or body
. if anything is passed to body
, it becomes a POST request, if just params
, then it's a GET request.
I needed to tweak the internals a bit, and now you can use startkey
and endkey
, see eg https://github.com/ropensci/sofa/blob/master/R/design_search.R#L123-L135
however, i still haven't figured out how to make it work for composite keys, maybe you will have luck with that.
Here is the version of sofa I am using:
Here is what I am trying, based on the view having a composite key on an ID value and a timestamp value:
Here is the result where the keys returned are completely out of range with the first key value having 17 unique values whereas I only specified exactly one, and the second value of the key being totally out of range where as I specified a range above:
Is there a different way to specify this correctly that I am missing? I also tried as follows with a vector instead of list and the output has no change:
When I inspect the documents returned, the key is correctly there as a 'list' with two items, the first being an id and the second being a timestamp: