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.