From user-return-16208-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sun May 15 22:25:19 2011 Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7A9894C98 for ; Sun, 15 May 2011 22:25:19 +0000 (UTC) Received: (qmail 26264 invoked by uid 500); 15 May 2011 22:25:17 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 26225 invoked by uid 500); 15 May 2011 22:25:17 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 26217 invoked by uid 99); 15 May 2011 22:25:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 May 2011 22:25:17 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,MIME_QP_LONG_LINE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_MED,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [128.18.84.113] (HELO mailgate-internal3.sri.com) (128.18.84.113) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 15 May 2011 22:25:11 +0000 Received: from brightmail-internal1.sri.com (128.18.84.121) by mailgate-internal3.sri.com with SMTP; 15 May 2011 22:24:50 -0000 X-AuditID: 80125479-b7c61ae000000cd9-96-4dd052b20d30 Received: from mars.esd.sri.com (mars.esd.sri.com [128.18.26.200]) by brightmail-internal1.sri.com (Symantec Brightmail Gateway) with SMTP id 08.B6.03289.2B250DD4; Sun, 15 May 2011 15:24:50 -0700 (PDT) MIME-version: 1.0 Received: from [192.168.1.18] (adsl-75-15-145-117.dsl.snlo01.sbcglobal.net [75.15.145.117]) by mars.esd.sri.com (Sun Java(tm) System Messaging Server 6.3-8.05 (built Sep 1 2009; 64bit)) with ESMTPSA id <0LL900HEICXCY700@mars.esd.sri.com> for user@couchdb.apache.org; Sun, 15 May 2011 15:24:49 -0700 (PDT) From: Jim Klo Content-type: multipart/signed; boundary=Apple-Mail-470-773574608; protocol="application/pkcs7-signature"; micalg=sha1 Subject: Re: fetching data: how to filter? Date: Sun, 15 May 2011 15:24:48 -0700 In-reply-to: To: user@couchdb.apache.org References: <0FE69EE5-B262-49E0-934C-AACBF0CB2242@sri.com> Message-id: <746D5AC7-6D03-4865-A6AC-F8F4E9684D63@sri.com> X-Mailer: Apple Mail (2.1084) X-Brightmail-Tracker: AAAAAA== --Apple-Mail-470-773574608 Content-Type: multipart/alternative; boundary=Apple-Mail-469-773574574 --Apple-Mail-469-773574574 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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=3D%22Beob= achtung%22&include_docs=3Dtrue 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? >=20 > Using a list seems like more work. >=20 > Alexander Gabriel >=20 >=20 >=20 >=20 > 2011/5/15 Jim Klo >=20 >> 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. >>=20 >> I suggest taking a look a Max Ogden's talk on CouchDB. It's a great >> jumpstart for a newbie. >>=20 >> http://vimeo.com/18808177 >>=20 >> - Jim >>=20 >>=20 >> On May 15, 2011, at 1:34 PM, Alexander Gabriel = wrote: >>=20 >>> 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 =3D Beobachtung. >>>=20 >>> So far I've tried: >>>=20 >>> - curl -d "{\"Typ\":\"Beobachtung\"}" -X POST >>>=20 >> = http://username:secretpassword@127.0.0.1:5984/evab/_bulk_docs?include_docs= =3Dtrue >>>=20 >>> Beobachtungen.json >>> - curl -d "{\"docs\": [{\"Typ\":\"Beobachtung\"}]}" -X POST >>>=20 >> = http://username:secretpassword@127.0.0.1:5984/evab/_all_docs?include_docs=3D= true >>>=20 >>> Beobachtungen.json >>> - replacing {\"Typ\":\"Beobachtung\"} or {\"docs\": >>> [{\"Typ\":\"Beobachtung\"}]} with "@TypBeob_Kriterien.json" to >> circumvent >>> problems with the windows-command-tool and " or '. >>>=20 >>> I consistently get all the data of all the docs in the CouchDb. >>>=20 >>> =46rom the documentation I have not understood: >>>=20 >>> - _all_docs or _bulk_docs? It seems that both work the same. >>> - Is ist maybe only possible to filter with keys =3D _id's? >>> - Is it possible to fetch the data from a view? >>>=20 >>>=20 >>> Or simply: What is the best way to do it? >>>=20 >>> Thanks for help! >>>=20 >>> Alexander Gabriel >>=20 --Apple-Mail-469-773574574 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii 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:


See http://wiki.apache.o= rg/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 = <jim.klo@sri.com>

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 <alex@barbalex.ch> = 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 =3D = Beobachtung.

So far I've = tried:

 - curl -d = "{\"Typ\":\"Beobachtung\"}" -X = POST

http://username:secretpassword@127.0.0.1:5984/evab/_bulk_= docs?include_docs=3Dtrue

Beobachtungen.json
 - curl -d "{\"docs\": = [{\"Typ\":\"Beobachtung\"}]}" -X = POST

http://username:secretpassword@127.0.0.1:5984/evab/_all_do= cs?include_docs=3Dtrue

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.

=46rom 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 =3D = _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


= --Apple-Mail-469-773574574-- --Apple-Mail-470-773574608 Content-Disposition: attachment; filename=smime.p7s Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJ/zCCBO0w ggRWoAMCAQICEBZ7jcIF++u6rxPdCkJYyG0wDQYJKoZIhvcNAQEFBQAwgdgxCzAJBgNVBAYTAlVT MRowGAYDVQQKExFTUkkgSW50ZXJuYXRpb25hbDEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0 d29yazE7MDkGA1UECxMyVGVybXMgb2YgdXNlIGF0IGh0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9y cGEgKGMpMDIxMDAuBgNVBAsTJ0NsYXNzIDIgT25TaXRlIElu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