An entity must match all filters to be a result. In the JDOQL string syntax,
you can separate multiple filters with || (logical "or") and && (logical
"and"), although keep in mind that || can only be employed when the filters
it separates all have the same field name. In other words, || is only legal
in situations where the filters it separates can be combined into a single
contains() filter:

    // legal, all filters separated by || are on the same field
    Query query = pm.newQuery(Employee.class,
                              "(lastName == 'Smith' || lastName == 'Jones')" +
                              " && firstName == 'Harold'");

    // not legal, filters separated by || are on different fields
    Query query = pm.newQuery(Employee.class,
                              "lastName == 'Smith' || firstName == 'Harold'");


On Sun, Sep 5, 2010 at 10:53 PM, killer barney <[email protected]> wrote:

> I'm a dunce. how does query filters help in the OR process?
>
> So do I do a query with contains "dog" and "cat"?
>
> On Sep 5, 8:44 pm, Nate Bauernfeind <[email protected]>
> wrote:
> > http://code.google.com/appengine/docs/java/datastore/queriesandindexe...
> >
> > See "Query Filters". Should answer your how-to question.
> >
> > In the backend it actually does two separate queries, but in parallel
> (then
> > does any merging/union-ing based on your entire query after retrieving
> the
> > results). There are some google tech talks on how the datastore works
> which
> > should give you a really good idea why it is done this way.
> >
> > On Sun, Sep 5, 2010 at 10:34 PM, killer barney <[email protected]>
> wrote:
> > > This is something I never figured out how to do.  How do you
> > > supplement an OR statement in datastore?
> >
> > > So let's say I have a user who sells Dogs and Cats.  How do I get a
> > > list of all of the dogs and cats that a user sells? I thought of 2
> > > ways, query both tables and combine the results in the backend or
> > > create an additional generic table Animals that tabulates all of the
> > > selling action into a list and search the Animals entries for that
> > > user.
> >
> > > I created this scenario just so you can have an idea of what I am
> > > looking for, but in reality, my "cats" table may consist of hundreds
> > > of users.  I'm not sure if creating a combined list property of Dog
> > > and Cat users is the way to go.  And doing two queries just doesn't
> > > seem right either.  Is there a better way to do this?
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Google App Engine" group.
> > > To post to this group, send email to [email protected]
> .
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-appengine%[email protected]>
> <google-appengine%[email protected]<google-appengine%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-appengine?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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-appengine?hl=en.

Reply via email to