I found that if I used my query a few times on the development server
then your above code snippet was automatically inserted in my
index.yaml - neat! (not app.yaml)
Then when I uploaded to Google App Engine I got errors for a few
minutes while the index was building, but eventually it worked.


On Oct 30, 12:02 pm, ryan baldwin <[email protected]> wrote:
> In my example I left out the sorts by A ascending because I later realised
> it may not be necessary... I believe, however, that my index *does* sort by
> createdDate ascending... I haven't written one in a long, long time, so my
> apologies. ;)
>
> - ryan.
>
> On Thu, Oct 29, 2009 at 7:01 PM, ryan baldwin <[email protected]> wrote:
> > I believe you can create an index that sorts by youngest, then by name, and
> > you should be good.  Assuming your "youngest" field is called "createdDate".
>
> > In app.yaml:
>
> >  - kind: MyModel
> >   properties:
> >     - name: createdDate
> >       direction: asc
>
> > If I understand what I just typed, that will create an index on the MyModel
> > entity, ordering first by createdDate ascending then by A ascending.  You
> > could, I believe, then do the following:
>
> > MyModel.all().filter=('A =', 123).order(createdDate).fetch(limit=20)
>
> > That being said, I'm not sure if DataStore actually guarantees the order of
> > results... I assume so...?
>
> > - ryan.
>
> > On Thu, Oct 29, 2009 at 6:53 PM, Baron <[email protected]> wrote:
>
> >> Hello,
>
> >> I have a model with over 1000 records and I want to select the top N
> >> records on field A that satisfy conditions on field B. (For example
> >> the youngest N records with a certain name.)
>
> >> My concern is if I only filter on field B and order in code
> >> afterwards, then I will miss some records not in the top 1000.
>
> >> I was hoping to create an index so that the results are always ordered
> >> by field A, but that doesn't seem to be possible.
> >> Ideas?
>
>
--~--~---------~--~----~------------~-------~--~----~
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