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