Multiple inequality filters work fine on a single valued property.. they
just don't work in the way you're trying on ListProperties.
Like I mentioned.. you could (assuming one were trying to filter on
startDate, endDate properties), assign the properties to date buckets, join
those date buckets together and add the value to the entity as a
startEndBucket property.
Then you could query using an IN filter on the startEndBucket using the
range of buckets that cover the dates you want for startDate and endDate.
(then trim out the fine grained results that don't match at the ends)
So, an entity with startDate = '2010-10-06' and endDate = '2010-10-28' would
have startEndBucket = '2010-10-04_2010-10-25' (if you mapped dates to the
nearest past Monday).
If you wanted to query for results with startDate > date1 AND endDate <
date2 (presuming startDate must always be less than endDate), you'd generate
the list of startEndBuckets that cover this date1 date2 range.
Pseudo code:
bucketList = [weekly date buckets covering date1 and date2]
for i in range(0,len(bucketList)):
for j in range(i,len(bucketList)):
startEndBuckets.append(str(bucketList[i]) + '_' + str(bucketList[j]))
Or some actually working, fine-tuned version of that.
Then use this query to get your initial results:
myModel.all().filter("startEndBucket IN", startEndBuckets)
Some results that get returned on the ends will need to be filtered in
memory.. but depending on how your data is queried.. you can set the buckets
up so that you can minimize the number of buckets that need to be grabbed
versus the number of returned results that have to be dropped.
If I understand the Appengine documentation correctly, something like this
would be restricted to 30 startEndBuckets (due to the 30 subquery limit with
IN filters).. so maybe you could make multiple versions of the
startEndBucket property if necessary.. weeklyStartEnd, monthlyStartEnd,
yearlyStartEnd, etc.
You could get even more sophisticated and do something like how Geohashing
is done if you liked.
On Sun, Oct 31, 2010 at 3:31 PM, johnterran <[email protected]> wrote:
> I tried using different values too.. it looks like production app
> engine disabled multiple inequality filters even for single property.
> it does sound a lot like 798. I guess it is a know issue then. I wish
> this was disabled in development server too.
>
> Next gen queries from youtube is what i want..I guess i didn't attend
> that session at I/O
>
> I'll filter the inequalities in memory
>
> Thanks guys.
>
> On Oct 31, 12:10 pm, Eli Jones <[email protected]> wrote:
> > If you read the first comment for that cookbook recipe, you see that it
> > says:
> >
> > "this recipe only works in the development server, this is a known issue"
> >
> > And that's from August 2009. Looks like this has been a known issue/bug
> > since Oct 2008.
> >
> > They are working on making multiple inequality filters do-able (See
> NextGen
> > IO talk):
> >
> > http://www.youtube.com/watch?v=ofhEyDBpngM#t=3m17s
> >
> > <http://www.youtube.com/watch?v=ofhEyDBpngM#t=3m17s>If you can't wait
> for
> > the next generation queries, you could create some sort of hash function
> > that takes the two properties you are doing the inequality filters on and
> > creates a quasi unique hash value.. as long as you didn't have too many
> > entities per hash value.. you could just query for the hash value then
> > literally filter the inequalities in memory.
> >
> >
> >
> >
> >
> >
> >
> > On Sun, Oct 31, 2010 at 1:31 PM, johnterran <[email protected]>
> wrote:
> > > This works in the development environment...
> > > Basically, since we can't use inequality filter on more than 1
> > > property, so I used a list to check for range.
> > > I followed the work around for range query from
> > >http://appengine-cookbook.appspot.com/recipe/how-to-query-by-date-range
> >
> > > If this doesn't work in production, how do I do a range query on
> > > BigTable (use 2 inequality filters)?
> >
> > > Thanks
> > > John
> >
> > > On Oct 31, 8:56 am, djidjadji <[email protected]> wrote:
> > > > Both your inequality long values are the same
> > > > timeRange > 1279593000
> > > > timeRange <= 1279593000
> >
> > > > No timeRange value will ever match these two criteria
> >
> > > > 2010/10/31 johnterran <[email protected]>:
> >
> > > > > Hi,
> >
> > > > > I am using this GQL range query and it works for me in the
> > > > > development.
> > > > > But once i deployed it to production, the query is not working,
> even
> > > > > from the admin console.
> > > > > And i can see the data, and it is within range..
> > > > > ie.
> > > > > SELECT * from Event WHERE timeRange > 1279593000 AND timeRange <=
> > > 1279593000
> >
> > > > > class Event(db.Model):
> > > > > name = db.StringProperty(required=True)
> > > > > timeRange = db.ListProperty(long)
> >
> > > > > one sample data
> > > > > Event.name Test
> > > > > Event.timeRange [1279591200L, 1279594800L]
> >
> > > > > Why does this work in development but not in production?
> > > > > I am running 1.3.7 in development due to datastore error in 1.3.8
> on
> > > > > win7
> >
> > > > > thanks
> > > > > John
> >
> > > > > --
> > > > > 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]<google-appengine%[email protected]><google-appengine%2Bunsubscrib
> [email protected]>
> > > .
> > > > > For more options, visit this group athttp://
> > > groups.google.com/group/google-appengine?hl=en.
> >
> > > --
> > > 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]<google-appengine%[email protected]><google-appengine%2Bunsubscrib
> [email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-appengine?hl=en.
>
> --
> 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]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>
--
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.