Hi Aaron, there are a number of ways of getting around the "exploding- index" problem. It's hard to offer a good solution without knowing what the end-result is that you are trying to accomplish.
If your sort order is immutable and can be determined when your entities are created, the best solution is to create a key_name that lexicographically represents the sort order (no need to add a .order() to your query object). However, if your sort order is dynamic I would suggest that you create a special model kind that de-normalizes the sort order and either the owners or the topics (basically, this would act as an index) and write some code that generates these index entities when your keywords are written. This will be an expensive write operation, both executing the code and writing to multiple entities (always remember to use batch put to write multiple entities), but your reads (which I am assuming are going to be significantly more frequent than writes) will be efficient. Obviously, the simple solution, If you can guarantee that your result set is small ( <1000 for a simple model like you described), would be to retrieve the entities and perform the sort in your code. Just remember that this will be an expensive request that will happen on all your reads (you could use memcache to mitigate it somewhat) Curious, what is the integer sort for? Good luck, --Joe Also, check out Brett Slatkin's "Building Scalable, Complex Apps on App Engine" http://www.youtube.com/watch?v=AgaL6NGpkB8 It's got a lot of great insights about data-modeling the GAE way. On Mar 11, 2:58 am, Aaron <[email protected]> wrote: > Hi, I'm currently running into an exploding index problem with the > following model: > class Keywords(db.Model): > owners_saved = db.ListProperty(db.Key)#list of user keys who saved > this keyword > topics = db.ListProperty(db.Key)#list of keys of topic objects > sort1property = db.IntegerProperty#need to sort by this > > Keywords can mark as saved, and I need to be able to query for > keywords a user has saved that are in a specific topic area. I'm > running into an exploding index problem because I need to be able to > query by a composite index on two list properties (owners_saved and > topics)...both list properties can potentially become really long. > > Can anyone suggest a way for me to be able to avoid the exploding > index problem AND be able to sort by property? > > Thanks in advance! -- 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.
