Multiple key query to CouchDB
Svetoslav Nedkov
snedkov at asteasolutions.com
Sat Feb 27 12:41:29 UTC 2010
Antranig Basman wrote:
> On 27/02/2010 01:43, Svetoslav Nedkov wrote:
>> Antranig Basman wrote:
>>> On 26/02/2010 07:32, Svetoslav Nedkov wrote:
>>>> Hi Colin,
>>>>
>>>> While looking for other information I stumbled upon a way to supply
>>>> multiple keys to a CouchDB view and retrieve multiple results
>>>> respectively.
>>>>
>>>> In short the solution is to make a POST request to the view and as
>>>> data
>>>> supply keys in the format {"keys": ["key1", "key2"..."keyn"]}.
>>>>
>>>> Here is an example:
>>>>
>>>> curl -X POST
>>>> http://142.150.154.59:5984/mccord/_design/artifacts/_view/viewByObjectCode
>>>>
>>>>
>>>> \
>>>> -d
>>>> '{"keys":[{"objectCode":"01","lang":"en"},{"objectCode":"09","lang":"en"},{"objectCode":"05","lang":"en"}]}'
>>>>
>>>>
>>>>
>>>
>>> Which view do we in fact have that requires queries by multiple keys?
>>> I don't see this in current "codeEntryService", and none of the views
>>> which are using Lucene views appear to require this capability... can
>>> explain? :P
>>>
>>> Cheers,
>>> Antranig.
>> Hi Antranig,
>>
>> We are using multiple keys in the query to the by_id Lucene view used by
>> My Collection.
>
> Thanks Sveto - can you explain why this is?
>
> Cheers,
> Antranig.
Well the collection data is separate from the artifact data and from a
user collection we extract the artifact ids and then go to query the
artifacts database issuing a single query for all the artifact ids. From
where the multiple keys.
You can have a look at:
https://source.fluidproject.org/svn/fluid/engage/fluid-engage-kettle/trunk/src/main/webapp/services/myCollection/js/myCollectionService.js
the fetchAndMapCollectedArtifacts function.
There might be a better solution though.
Regards,
Svetoslav
More information about the fluid-work
mailing list