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 B6145118A7 for ; Mon, 9 Jun 2014 21:34:33 +0000 (UTC) Received: (qmail 42966 invoked by uid 500); 9 Jun 2014 21:34:32 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 42910 invoked by uid 500); 9 Jun 2014 21:34:32 -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 42900 invoked by uid 99); 9 Jun 2014 21:34:32 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jun 2014 21:34:32 +0000 Received: from localhost (HELO [192.168.1.8]) (127.0.0.1) (smtp-auth username rnewson, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jun 2014 21:34:32 +0000 From: Robert Samuel Newson Content-Type: multipart/signed; boundary="Apple-Mail=_AAE8815C-368C-4F7B-BE1A-C05DA5AF3A6D"; protocol="application/pgp-signature"; micalg=pgp-sha512 Message-Id: Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\)) Subject: Re: Question on views Date: Mon, 9 Jun 2014 22:34:22 +0100 References: <14256C9E890B874D989F0828DDB264F2C51F2C86@MX45A.corp.emc.com> <5395E772.5090108@gandrade.net> <14256C9E890B874D989F0828DDB264F2C51F2CB5@MX45A.corp.emc.com> <5395FA14.30506@gandrade.net> To: user In-Reply-To: <5395FA14.30506@gandrade.net> X-Mailer: Apple Mail (2.1878.2) --Apple-Mail=_AAE8815C-368C-4F7B-BE1A-C05DA5AF3A6D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 There are no wildcards. :) Views are fully ordered by the key value according to the defined = collation order documented here: = https://wiki.apache.org/couchdb/View_collation Your example startkey=3D["target ID"]&endkey=3D["target ID",{}]=20 This works for any number or string in the second position, as any = object is 'higher' than any number or string. If you emitted objects as = the second item, then the query would not return any non-empty object in = that position. Views support exact key lookup and contiguous key range lookup only. A = POST variant lets you perform multiple exact key lookups in a single = request as a refinement. B. On 9 Jun 2014, at 19:16, Guilherme Andrade wrote: > I'm sorry, it looks like I've induced you in error; too much Erlang = ;). In any case, range queries make use of 'startkey' and 'endkey' = instead of just 'key'. >=20 > I don't remember the exact syntax for complete wildcards but Stack = Overflow gave me the answer. Looks like this might do: >=20 > startkey=3D["target ID"]&endkey=3D["target ID",{}]=20 >=20 >=20 > Cheers, >=20 >=20 > [1]: = https://stackoverflow.com/questions/11623154/couchdb-querying-array-key-va= lue-for-first-key-element-only >=20 > On 09-06-2014 19:05, Ramanadham, Radhika wrote: >> Thanks. >> I think I can change the keys -> key2, key1.=20 >> What would be the query? >>=20 >> The below throws me an error. >>=20 >>=20 >> = http://127.0.0.1:5984/longevity/_design/perfstats/_view/by_server?key=3D >> [key2,_] >>=20 >> example: >>=20 >>=20 >> = http://127.0.0.1:5984/longevity/_design/perfstats/_view/by_server?key=3D >> [" lglod025.lss.emc.com",_] >>=20 >> What am I doing wrong? >>=20 >> -----Original Message----- >> From: Guilherme Andrade [ >> mailto:g@gandrade.net >> ]=20 >> Sent: Monday, June 09, 2014 12:57 PM >> To:=20 >> user@couchdb.apache.org >>=20 >> Subject: Re: Question on views >>=20 >> Unfortunately there's no performant way to do it like that, views = have strict ordering and ranges/subranges are only possible within the = confinements of the composite key order. >>=20 >> One way to do it is to have a second view that emits keys in reverse = ([key2, key1]); then you may do a range query based on [key2, _]. >>=20 >> Cheers, >>=20 >> On 09-06-2014 17:36, Ramanadham, Radhika wrote: >>=20 >>> Hi, >>>=20 >>> I have a view which has 2 keys- key1 and key2: >>>=20 >>> "by_server": { >>> "map": "function(doc) { if ((doc.type =3D=3D = 'performance_stats')) emit([key1, key2],{ 'Start_time':doc.start_time = ,'CPU': doc.CPU, 'Memory': doc.Memory, 'FileSystem':doc.FileSystem }) }" >>> }, >>>=20 >>>=20 >>> If I want to query the view where I need all the rows for key2 and = key1 being anything, how do I do it? >>>=20 >>> Let's say my data is-> >>>=20 >>> = {"id":"server_lglod025.lss.emc.com_2014-06-09_10:24:18","key":["lglod0 >>> = 25.lss.emc.com","SRMSuite_3.0.2_test1"],"value":{"Start_time":"2014-06 >>> -09 09:00:00","CPU":12,"Memory":98,"FileSystem":96}}, >>> = {"id":"server_lglod093.lss.emc.com_2014-06-09_11:24:18","key":["lglod0 >>> = 93.lss.emc.com","SRMSuite_3.0.2_test2"],"value":{"Start_time":"2014-06 >>> -09 10:00:00","CPU":12,"Memory":98,"FileSystem":97}}, >>> = {"id":"server_lglod174.lss.emc.com_2014-06-04_14:01:44","key":["lglod1 >>> = 74.lss.emc.com","SRMSuite_3.0.2_test2"],"value":{"Start_time":"2014-06 >>> -04 10:00:00","CPU":67,"Memory":97,"FileSystem":17}}, >>>=20 >>> I only want the below 2 rows who have a key2 =3D = SRMSuite_3.0.2_test2, how do I do it? >>>=20 >>> = {"id":"server_lglod093.lss.emc.com_2014-06-09_11:24:18","key":["lglod0 >>> = 93.lss.emc.com","SRMSuite_3.0.2_test2"],"value":{"Start_time":"2014-06 >>> -09 10:00:00","CPU":12,"Memory":98,"FileSystem":97}}, >>> = {"id":"server_lglod174.lss.emc.com_2014-06-04_14:01:44","key":["lglod1 >>> = 74.lss.emc.com","SRMSuite_3.0.2_test2"],"value":{"Start_time":"2014-06 >>> -04 10:00:00","CPU":67,"Memory":97,"FileSystem":17}}, >>>=20 >>> Thanks, >>> Radhika >>>=20 >>>=20 >> -- >> Guilherme Andrade >>=20 >> PGP fingerprint: 1968 5252 3901 B40F ED8A D67A 9330 79B1 35CB 8191 >>=20 >>=20 >>=20 >=20 > --=20 > Guilherme Andrade >=20 > PGP fingerprint: 1968 5252 3901 B40F ED8A D67A 9330 79B1 35CB 8191 >=20 --Apple-Mail=_AAE8815C-368C-4F7B-BE1A-C05DA5AF3A6D Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJTlihjAAoJEBAV9o+doki8hYQQAKDk4GirYkwBb51edBGm9BVi bx1FgdSJIOK8e5hSLaWAQPfw1zJJTRi8fAj+OE+LMRAOxMO+fFiON6iq64fQ3QOW fJo8GP0DVqpr0S3aDZWD5WVfvpcpfRypORhveGJWTjAQrJzAVhsnqsF5SP0hqSuq 9Rq7zkin/QvUS7ZPF9KccK+7ndnWYjGKYentgOGAILStracYPSfgTHDnLVWb/223 Mk6wyo7OVYa45XWOqLeP8z2vv+kcX3OIcqcuF+4ugJATkU0ZKvkE0CKAp33PPRvG fGdgjsc6q2F+yOer8HwcXFfCNGucyX2urg9Jx4sSthq85snAvEgaAO7YULVhTPIz 0Esnr3qnKiVQTZJrW5aheywF0NF/s7hGnTa1SWFkVLbzxm9pVREjaHNcbhOyL1Aj 5hsC5hkGRk+o98OhsD9x6TjSJ4PCM6mjK6fpGDmb9bYlscCibsfQBGtHAP1noSmI 9BiM1rs2b46JLqL5Fhjn2RLNkf7tjiXHa4uoR8s+VvFRoEm6Fo5FfpR45qORz5fV ucX8mC7Zwtaej0fWXw1S+svgSgTL5kYsWHggX1ZU69jDjV3ROx1K41UAO3AvcWRL V4LVOINWufNINqtyyXgo//1vDYUSuVJh8zQRbsweY56MX3a9A5ctC6uEWzs+peNM cV4RIeT/5sP4pkir8Gi5 =QvSZ -----END PGP SIGNATURE----- --Apple-Mail=_AAE8815C-368C-4F7B-BE1A-C05DA5AF3A6D--