I just discovered the following post:

http://www.mail-archive.com/[email protected]/msg01441.html

That talks about attributes being multi-valued, so non-aggregate
functions won't work without first applying an aggregate function.
So, I tried the following:

[x = quantity(int) : if ( int(max(x)) %26 2 == 0 ) then max(x) else
fail()]

Which worked!

Thanks for your help.  Any other advice is always appreciated.

Josh

On Jul 11, 6:39 pm, Josh Cummings <[email protected]> wrote:
> Hi, Tom -
>
> Basically, I'm trying to roll an arbitrary number of "pseudo"
> attributes into one attribute using prime numbers.  Each attribute is
> a composite number whose factors indicate characteristics about the
> record.  The reason that I want to roll them into one attribute is
> because the number of "pseudo" attributes will be arbitrary for each
> record.
>
> So, what I'd *really* love to do is something I would guess is not
> supported:
>
> ...snippets?bq=[myattribute % 2:0] ...other criteria...
>
> to extract those records that bear the characteristic represented by
> the prime number "2".
>
> So, I saw that the ranking language supports modular arithmetic, and
> thought I would give it a shot.
>
> With some more testing, I'm only able to get "exists" and aggregate
> functions, like "max", to succeed, regardless of the property that I
> pick (including bedrooms).  All the other functions return the same
> behavior that I mentioned, so I would suppose that I am
> misunderstanding the context in which the other functions ought to be
> used.
>
> With respect to your question, I haven't hashed the data, yet, and so
> all my queries are currently just on existing google base data in
> order to find out if my approach will work before I put the time into
> it; however, here is an example of one of my tests:
>
> http://www.google.com/base/feeds/snippets?bq=[quantity(int)]&orderby=[x
> = quantity(int): if (exists(x) %26 floor(x) %25 2 == 0) then x else
> fail()]
>
> What I would expect from this is that it would be ordered by the
> quantity attribute, and records whose quantity attribute wasn't an
> even number (x % 2 == 0 is a test for evenness) would be discarded.
>
> Hope that helps shed more light on my question.
>
> Josh
>
> P.S.:  The purpose of this post is to try and make this particular
> approach work, if possible.  If it's not possible, I'll create a
> separate post to investigate other possible approaches to address the
> overarching need.
>
> On Jul 11, 2:39 pm, Tom Wilson <[email protected]> wrote:
>
> > Can you provide example queries ? Why exactly are you trying to search
> > on this attribute and whats its for  ?
>
> > Tom Wilson
> > Freelance Google Base Developer and Consultantwww.tomthedeveloper.com
>
> > Google Base Tools -http://dev.tomthedeveloper.com/googlebase
> > Featured Project 
> > :http://google-code-featured.blogspot.com/2008/02/google-base-competit...
>
> > On Jul 11, 3:46 pm, Josh Cummings <[email protected]> wrote:
>
> > > I am trying to use the follow expression to rank my items:
>
> > > orderby=[x = myattribute(int): if (x%252==0) then x else fail()]
>
> > > (The %25 evaluates to '%')
>
> > > I get the following back:
>
> > > "Invalid expression: malformed expression: (x % 2); expected operand
> > > of type int, but found myattribute(int)"
>
> > > 'myattribute' is a custom attribute which I supply in a data feed like
> > > this 'c:myattribute:integer'.  When I pull up the item for editing, it
> > > displays as type 'Number'.
>
> > > I wondered if it was because 'myattribute' is a custom attribute, so I
> > > also tried 'quantity' with the same results.
>
> > > What do I need to change?
>
> > > Thanks,
> > > Josh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Base Data API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Base-data-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to