This approach may present other problems; for one thing, App Engine's index
generation is not dynamic, so you will have to manually build index entries
(or let the development server generate them for you during testing) for
each combination of potential query inputs. Once the indexes are built, you
will have to do more work at query time since having a boolean for each
combination of inputs isn't realistic. In general, App Engine works best
with well-defined queries though depending on the number of inputs and
possible combinations, it's likely that you could get something working with
App Engine.

OR isn't supported due to the way Bigtable, which App Engine's datastore is
built on top of, works, and this isn't going to change soon. For more
low-level details, check out the video from this I/O session:

https://sites.google.com/site/io/under-the-covers-of-the-google-app-engine-datastore

- Jason

On Tue, Oct 27, 2009 at 3:50 PM, king <kingalpha...@gmail.com> wrote:

>
> Jason, thanks for the feedback.  The issue with this boolean approach
> is that the queries are all dynamically generated, depending on the
> options selected in the search configurator.  So there is no way to
> know at record write time what flags to set unless I work out
> thousands of possible boolean flags in advance (full permutation of
> all the ever expanding filter values available, such as in the
> schoolPreference ArrayList, we keep adding new schools, which can be
> an infinite set).  Any other workaround is greatly welcome.
>
> Is the OR query operator on the roadmap for GAE?  If so, what time
> frame would that be?
>
>
>
> On Oct 27, 2:41 pm, "Jason (Google)" <apija...@google.com> wrote:
> > While App Engine's datastore does limit which queries you're able to
> > execute, there are various workarounds, which, while not ideal from a
> > development point of view, do ensure that query execution time is
> minimized
> > so your app can achieve the best possible scalability. One common pattern
> is
> > determining whether an entity meets the conditions of a certain query at
> > write time, then setting a boolean flag on that entity. When you need to
> run
> > the query, instead of managing multiple sub-queries and merging, you only
> > need to filter on this boolean field. When new queries are added, you can
> > run a task to re-process all existing entities and set their flags
> > accordingly. This is quite different from executing your query on
> runtime,
> > but should be much more efficient.
> >
> > - Jason
> >
> >
> >
> > On Mon, Oct 26, 2009 at 10:22 AM, king <kingalpha...@gmail.com> wrote:
> >
> > > Hi there, can anyone from Google shines some light on the issue I
> > > posted last week?  I just need to find out if it is a major limitation
> > > on google's part with no workaround so that I can move forward
> > > accordingly. Thanks a lot.
> >
> > > On Oct 23, 11:01 am, king <kingalpha...@gmail.com> wrote:
> > > > Thanks so much for the feedback.  I actually tried to extend the Key
> > > > CONTAINS concept to other fields but ran into a big wall right away.
> > > > It would be great to get your 2 cents.  Here is the root of my
> > > > problem:
> >
> > > > I have a student object, it has a number of qualifying attributes,
> for
> > > > example:
> > > > int gpa: 1 = 0 to 2.0, 2 = 2.0 to 3.0, 3 = 3.0 to 4.0
> > > > int ageGroup: 1 = 0 to 17, 2 = 18 to 30, 3 = 30 to 65, 4 = 65+
> > > > ArrayList schoolPreference: [0] = 'MIT', [1] = 'Stanford', [2] =
> > > > 'Harvard', [3] = 'Yale'
> >
> > > > Now, I need to create a query to find out all the students where (gpa
> > > > = 2 or gpa = 3) AND (age group = 3 or age group = 4) AND
> > > > (schoolPreference contains MIT or Yale, or both)
> >
> > > > As far as I know, GAE doesn't support OR operator in a query, so the
> > > > only way I can get the query above to work is to have multiple sub-
> > > > queries and do a manual join on all the datastore resultsets to
> > > > artificially create a union. If so, big problem arises:
> >
> > > > Since I have so many OR sub-conditions, if every OR translates into a
> > > > separate sub-query, literally speaking, I need to do a full
> > > > permutation of all the conditions (full product of all the OR and AND
> > > > conditions)  in all my sub-queries to achieve my goal, which doesn't
> > > > make any sense if I keep adding more value types (such as more
> schools
> > > > being selected in the student preference criteria) into my
> attributes,
> > > > not to mention adding more attributes to my student object.  Is there
> > > > any way to accomplish this query in GAE?  Your help is greatly
> > > > appreciated because this can be the deal breaker of whether my whole
> > > > project can migrate to GAE or not.  Thanks a lot in advance.
> >
> > > > On Oct 23, 1:51 am, Yasuo Higa <higaya...@gmail.com> wrote:
> >
> > > > > Hi Andy,
> >
> > > > > >> query.setFilter("key == :keyList");
> > > > > >> List<Master> list = (List<Master>) query.execute(keyList);
> >
> > > > > > I'd like to know if that works with GAE/J, because it is illegal
> > > JDOQL
> > > > > > syntax and would be a bug. JDOQL is supposed to follow Java
> syntax,
> > > > > > and you simply cannot do
> > > > > > Key == List<Key>
> > > > > > and get success in Java.
> >
> > > > > You are right, but unfortunately the above query works on GAE/J.
> >
> > > > > I should have recommended the following query:
> >
> > > > > List<Key> keys = ...;
> > > > > List<Object> ids = new ArrayList<Object>();
> > > > > for (Key key : keys) {
> > > > >     ids.add(pm.newObjectIdInstance(Master.class, key));}
> >
> > > > > List<Master> list = (List<Master>) pm.getObjectsById(ids);
> >
> > > > > Thanks,
> >
> > > > > Yasuo Higa
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to