To understand views: http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views
A map function might look like:
function (doc) {
if (doc.Typ) {
emit(doc.Typ, null);
}
}
then to query the view:
curl -X GET
"http://localhost:5981/dbname/_design/docname/_view/viewname?key=%22Beobachtung%22&include_docs=true
See http://wiki.apache.org/couchdb/HTTP_view_API for details on querying views
and other options.
Jim Klo
Senior Software Engineer
Center for Software Engineering
SRI International
On May 15, 2011, at 2:18 PM, Alexander Gabriel wrote:
> thanks a lot for your help. So I can define a view that includes the Typ
> field and filter for it.
> But how do I fetch the data from the view using curl?
>
> Using a list seems like more work.
>
> Alexander Gabriel
>
>
>
>
> 2011/5/15 Jim Klo <[email protected]>
>
>> You need to define a view, using the name as at least part of the key or
>> create a list. Then you can filter using the key in a view or some parameter
>> you pass using a list.
>>
>> I suggest taking a look a Max Ogden's talk on CouchDB. It's a great
>> jumpstart for a newbie.
>>
>> http://vimeo.com/18808177
>>
>> - Jim
>>
>>
>> On May 15, 2011, at 1:34 PM, Alexander Gabriel <[email protected]> wrote:
>>
>>> Hi
>>> I want to fetch documents from a CouchDb named evab. The documents
>> include a
>>> field "Typ" and I want to fetch those with Typ = Beobachtung.
>>>
>>> So far I've tried:
>>>
>>> - curl -d "{\"Typ\":\"Beobachtung\"}" -X POST
>>>
>> http://username:[email protected]:5984/evab/_bulk_docs?include_docs=true
>>>
>>> Beobachtungen.json
>>> - curl -d "{\"docs\": [{\"Typ\":\"Beobachtung\"}]}" -X POST
>>>
>> http://username:[email protected]:5984/evab/_all_docs?include_docs=true
>>>
>>> Beobachtungen.json
>>> - replacing {\"Typ\":\"Beobachtung\"} or {\"docs\":
>>> [{\"Typ\":\"Beobachtung\"}]} with "@TypBeob_Kriterien.json" to
>> circumvent
>>> problems with the windows-command-tool and " or '.
>>>
>>> I consistently get all the data of all the docs in the CouchDb.
>>>
>>> From the documentation I have not understood:
>>>
>>> - _all_docs or _bulk_docs? It seems that both work the same.
>>> - Is ist maybe only possible to filter with keys = _id's?
>>> - Is it possible to fetch the data from a view?
>>>
>>>
>>> Or simply: What is the best way to do it?
>>>
>>> Thanks for help!
>>>
>>> Alexander Gabriel
>>
smime.p7s
Description: S/MIME cryptographic signature
