This doesn't make sense to me.

Every scrap of documentation I've found says that GAE queries only
follow a single index (the one exception being zigzag merges, which
don't apply here).  This means that to answer my query.filter(foo,
"fooValue1").sort("-bar"), there must be an index that contains the
foo and bar data sorted appropriately, no?  Ie:

/Thing/foo:fooValue1/bar:bar9/[thekeyvalue]
/Thing/foo:fooValue1/bar:bar8/[thekeyvalue]
/Thing/foo:fooValue1/bar:bar7/[thekeyvalue]
/Thing/foo:fooValue2/bar:bar8/[thekeyvalue]
/Thing/foo:fooValue2/bar:bar7/[thekeyvalue]

To satisfy this query, GAE should start following this custom index
and that's pretty much it.  There's no reason for it to touch the
single-property indexes (foo ASC, foo DESC, bar ASC, and bar DESC).

...and in my test, if I remove the custom index from
datastore-indexes.xml, it doesn't work.  But also if I use
setUnindexedProperty, it doesn't work.

It's like setUnindexedProperty is being interpreted as "not only don't
set single-property indexes, but also don't include the property in
any custom indexes".  This is counterintuitive - if I wanted the index
not to be built, I can just remove the index.

I realize now that perhaps I posted this to the wrong mailing list.
The guys who created the I/O videos about the datastore seem to be
python fans, so I'll retry my original post on the google-appengine
list.

Jeff

On Thu, Mar 18, 2010 at 8:00 AM, Tristan <[email protected]> wrote:
> Not official but been doing this for a while.
>
> Your custom index is most likely build from the query. So, when you
> do
>
>        Query query = new Query("Thing");
>        query.addFilter("foo", FilterOperator.EQUAL, "fooValue");
>        query.addSort("bar", SortDirection.DESCENDING);
>
> That is what builds your custom index.
>
> However, when you setUnindexedProperty here
>
>        Entity ent = new Entity("Thing");
>        ent.setUnindexedProperty("foo", "fooValue");
>        ent.setUnindexedProperty("bar", 123L);
>
> You are not generating any index entries.
>
> So the issue isn't that "adding custom indexes after-the-fact [is]
> really, really painful" but that you are not generating any indexes
> for the datastore to run the queries against when you use
> setUnindexedProperty(). In other words, when you execute a query, it
> checks the index to give you results. But you marked your data as
> "don't index me," so there is nothing for query to work with, as far
> as it is concerned, there's nothing in the datastore.
>
> Cheers!
>
>
> On Mar 16, 4:07 pm, Jeff Schnitzer <[email protected]> wrote:
>> On Mon, Mar 15, 2010 at 11:04 PM, John Patterson <[email protected]> 
>> wrote:
>>
>> > On 16 Mar 2010, at 12:25, Jeff Schnitzer wrote:
>>
>> >> I'm puzzled by the behavior of custom indexes.  I have a simple test
>> >> case below, a simple equality filter on one property combined with a
>> >> descending sort on another property.  If I set the properties with
>> >> setUnindexedProperty(), the query fails to find the result.  If I set
>> >> the properties with setProperty(), it does.
>>
>> > I also wondered why - I assume that the custom index build reads the single
>> > property indexes directly which must be more efficient than reading the
>> > Entities "table".
>>
>> I guess that is possible, but seems like a poor design decision.  It
>> makes adding custom indexes after-the-fact really, really painful.
>>
>> Can someone official chime in on this?  Is it intended behavior, or
>> should we file an issue against it?  The documentation doesn't say
>> much on the subject, and all the conceptual explanation of queries
>> suggests that these extra single-property indexes will be unused.
>>
>> Jeff
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine for Java" 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-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" 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-java?hl=en.

Reply via email to