For those of you reading this thread on appengine-java, I apologize.
However, I realized that this is really a general appengine question
and might get a better response from someone "in the know" here.
Here's the appengine-java thread:
http://groups.google.com/group/google-appengine-java/browse_thread/thread/efed35cabf60f6ee
----------
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.
Why? I have a custom index, therefore the query should not need or
touch the single-property indexes on these fields, right?
With this requirement, adding a single custom index means the
datastore must now update (at least) five indexes on every put() - the
single-value ASC and DESC indexes of both properties as well as my
custom index. That's gotta hurt.
Here's a test case using the low-level API:
/** */
@Test
public void lowLevelTest() throws Exception
{
DatastoreService service = DatastoreServiceFactory.getDatastoreService();
Entity ent = new Entity("Thing");
ent.setUnindexedProperty("foo", "fooValue");
ent.setUnindexedProperty("bar", 123L);
// switching to this works
//ent.setProperty("foo", "fooValue");
//ent.setProperty("bar", 123L);
service.put(ent);
Query query = new Query("Thing");
query.addFilter("foo", FilterOperator.EQUAL, "fooValue");
query.addSort("bar", SortDirection.DESCENDING);
PreparedQuery pq = service.prepare(query);
int count = 0;
for (Entity fetched: pq.asIterable())
{
count++;
}
assert count == 1;
}
The last assertion fails. The query doesn't find any results. The
automatic datastore index seems to be fine:
<!-- Indices written at Mon, 15 Mar 2010 21:49:01 PDT -->
<datastore-indexes>
<!-- Used 1 time in query history -->
<datastore-index kind="Thing" ancestor="false" source="auto">
<property name="foo" direction="asc"/>
<property name="bar" direction="desc"/>
</datastore-index>
</datastore-indexes>
What's up? Is this just a bug in the dev mode, or is there a real
requirement that all properties must have single-value indexes in
order to be part of a custom index?
Thanks,
Jeff
--
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.