couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From afshin afzali <a.afzali2...@gmail.com>
Subject Re: Newbie Question about View's Startkey Match
Date Thu, 01 Jul 2010 21:00:29 GMT
Hi Robert,

You mean if I want to be able to use a don't care key for example for any of
my arrays, I should insert a fixed constant element in all of them ?

-- afshin

On Fri, Jul 2, 2010 at 1:19 AM, Robert Newson <robert.newson@gmail.com>wrote:

> Afshin,
>
> Unfortunately, none of your four assumptions are correct.
>
> CouchDB supports key and key range lookup only, there is no syntax for
> "match all arrays" or "match all objects".
>
> What you have probably seen is this trick;
>
> ?startkey=["foo"]&endkey=["foo",{}]
>
> which, in most circumstances, selects all array keys where the first
> item is a string of "foo". This works because shorter arrays sort
> before longer arrays and {} (empty object) sorts later than any
> possible string.
>
> As Zachary pointed out above, the view collation is described at
> http://wiki.apache.org/couchdb/View_collation.
>
> B.
>
> On Thu, Jul 1, 2010 at 9:30 PM, Zachary Zolton <zachary.zolton@gmail.com>
> wrote:
> > Afshin,
> >
> > Well, if you want to just get a certain "slice" of a view's key space,
> > you'll want to use both the startkey and endkey parameters.
> >
> > For instance, if you just want all the view rows where the key
> > contains an array, try this:
> >
> > startkey=[]&endkey={}
> >
> > Any array value (e.g. ["foo"] or ["foo","bar"]) will collate at or
> > after the empty array (i.e. []), and since in this example you don't
> > want any object keys coming through we stop at the empty object (i.e.
> > {}).
> >
> > Is this any clearer?
> >
> > -Zach
> >
> > On Thu, Jul 1, 2010 at 3:04 PM, afshin afzali <a.afzali2003@gmail.com>
> wrote:
> >> Thank you, I've saw this page already. My question is based on that
> page.
> >> Are you confirm my assumtions ?
> >>
> >>
> >>
> >>
> >> On Fri, Jul 2, 2010 at 12:26 AM, Zachary Zolton <
> zachary.zolton@gmail.com>wrote:
> >>
> >>> Here's the overall ordering of collation:
> >>> http://wiki.apache.org/couchdb/View_collation#Collation_Specification
> >>>
> >>> On Thu, Jul 1, 2010 at 2:31 PM, afshin afzali <a.afzali2003@gmail.com>
> >>> wrote:
> >>> > Hi Guys,
> >>> >
> >>> > These are some simple assumptions which I would be confirmed when
> using
> >>> in
> >>> > startkey param:
> >>> >
> >>> > 1) {} matches all object keys ( including {} )
> >>> > 2) [] matches all array keys (including [] )
> >>> > 3) "" (null string) matches all string keys (including "")
> >>> > 4) {} at the end of complex key matches all of remained ones
> >>> >
> >>> > BEST
> >>> > -- afshin
> >>> >
> >>>
> >>
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message