OMG......now I get how to use 2i in map reduce.  For the life of me I could
never get it to click in my brain.  Anyway....it worked.  Very cool.

Nonetheless I am still curious about why using key filters would not work.

Thanks


On Mon, Dec 24, 2012 at 8:57 PM, Sean Cribbs <s...@basho.com> wrote:

> David,
>
> Perhaps key filters are the wrong approach. Are you using the LevelDB
> backend? If so, then a secondary index lookup on the special '$key'
> index is what you need.  I can't tell from your examples above what
> language/client you're using but here's how the raw inputs would look
> in the JSON:
>
> {
>   "bucket":"yourbucket", // change this to your bucket name
>   "index":"$key",
>   "start":"2012123000",  // beginning of your range
>   "end":"2012122323"  // end of your range
> }
>
> Not only is this simpler to express, but it also limits the range of
> scans done in the backend, meaning your queries shouldn't take as long
> to complete.
>
> On Mon, Dec 24, 2012 at 2:16 AM, David Montgomery
> <davidmontgom...@gmail.com> wrote:
> > Thanks,
> >
> > If I use a logical & I get no data.
> >
> > If I just use a greater than than it works.
> >
> >  date_start = '2012122300'
> >  date_end =   '2012122323'
> >
> >  filters =  key_filter.tokenize(":",
> > filter_map['date']).greater_than_eq(date_start) &
> key_filter.tokenize(":",
> > filter_map['date']).less_than_eq(date_end)
> >  query.add_key_filters(filters)
> >
> >
> > filters = key_filter.tokenize(":", 4) +
> > (key_filter.string_to_int().greater_than_eq(date_start))
> > query.add_key_filters(filters)
> >
> > I event tried between
> >
> >  filters = key_filter.tokenize(":", 4) +
> > (key_filter.between(date_start,date_end))
> >  query.add_key_filters(filters)
> >  print filters
> >
> > These are the results for one day.  I am really at a loss as to why I
> cant
> > get riak to work with what should be very simple logical conditions
> >
> > cid5989410021||null||2012122314 1
> > cid5989410021||null||2012122306 1
> > cid5989410021||www.sonems.net||2012122305 1
> > cid5989410021||www.ke5ter.com||2012122406 1
> > cid5989410021||mobile.brothersoft.com||2012122315 1
> > cid5989410021||www.renotalk.com||2012122315 1
> >
> >
> >
> > query.map('''
> >     function(value, keyData, arg) {
> >
> >         if(value.length == 0){
> >            return [];
> >         }else{
> >
> >             var data = Riak.mapValuesJson(value)[0];
> >             var obj = {};
> >             var xs = value.key.split(':');
> >             var dt = xs[3];
> >             if(data['adx']=='gdn'){
> >                 try{
> >                     var matches =
> > data['url'].match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
> >                     var domain = matches && matches[1];
> >                     var alt_key = data['campaign_id'] + '||' + domain +
> '||'
> > +  dt;
> >                 }
> >                 catch(err){
> >                     var alt_key = 'error';
> >                 }
> >                 var obj = {};
> >                 obj[alt_key] = 1;
> >                 return [ obj ];
> >             }else{
> >                return [];
> >             }
> >         }
> >     }''')
> >
> > reducer = """
> >     function(values, arg){
> >
> >         if(values.length == 0){
> >             return [{}]
> >         }
> >         return [ values.reduce( function(acc, item) {
> >             for (var state in item) {
> >                 if (acc[state])
> >                     acc[state] += item[state];
> >                 else
> >                     acc[state] = item[state];
> >             }
> >             return acc;
> >         })];
> >     }
> >
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Dec 24, 2012 at 7:19 AM, Evan Vigil-McClanahan
> > <emcclana...@basho.com> wrote:
> >>
> >> It looks to me like your error is here:
> >>
> >> > filters = key_filter.tokenize(":", 4) +
> >> > (key_filter.starts_with('20121223') and
> >> > key_filter.string_to_int().less_than(2012122423))
> >>
> >> The 'and' there is getting interpreted as a logical and:
> >>
> >> >>> key_filter.starts_with('20121223') and
> >> >>> key_filter.string_to_int().less_than(2012122423)
> >> [['string_to_int'], ['less_than', 2012122423]]
> >>
> >> You have to use the sadly non-idiomatic '&' to get it to do what
> >> you're trying to do:
> >>
> >> >>> key_filter.tokenize(":", 4) + (key_filter.starts_with('20121223') &
> >> >>> key_filter.string_to_int().less_than(2012122423))
> >> [['tokenize', ':', 4], ['and', [['starts_with', '20121223']],
> >> [['string_to_int'], ['less_than', 2012122423]]]]
> >
> >
> >
> > _______________________________________________
> > riak-users mailing list
> > riak-users@lists.basho.com
> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> >
>
>
>
> --
> Sean Cribbs <s...@basho.com>
> Software Engineer
> Basho Technologies, Inc.
> http://basho.com/
>
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to