views:

118

answers:

2

I'm aware that app engine has the restriction of "Inequality Filters Are Allowed On One Property Only" as described here: http://code.google.com/appengine/docs/python/datastore/queriesandindexes.html#Introducing_Indexes

However is there some way to essentially run two filters, or is this simply not possible? For instance, if I had an entity kind that simply had an X and Y coordinate, and I wanted all entities that are within a certain range of X1 to X2 and Y1 to Y2, is there some way to query for all entities from X1 to X2 sorted by their Y values and then easily grab the relevant ones between my desired range for the Y values?

If so, does someone have some example code to demonstrate?

+1  A: 

If it suits your data, you can discretize your X and Y into bins, generate a hash of the two values, and store that on the model. Then you can do exact lookups for the hash(es) which overlap the region you want to search within. Then, manually filter out the results which are outside your region.

This is essentially what geomodel is doing for latitude/longitude.

Saxon Druce
A: 

According to Alfred Fuller's recent Google I/O talk, they're working on support for multiple inequality filters on numeric properties.

Drew Sears