query with multiple properties

471 views
Skip to first unread message

pac

unread,
Jun 8, 2010, 9:06:05 AM6/8/10
to objectify-appengine
I am using objectify and not sure if I am using it in a right way.
I want to query a kind with 2 properties e.g.
Query<T> q = ofy().query(someclazz);
q.filter("country", "somecountry").filter("city", "somecity")

It works, but in dev env it doesnt create index in datastore-indexes-
auto.xml
Whats the right way to do query in objectify with multiple properties
and one property with multiple values?
Thanks.

Jeff Schnitzer

unread,
Jun 8, 2010, 12:29:29 PM6/8/10
to objectify...@googlegroups.com
That should work. When I issue filters like this I get an updated
datastore-indexs-auto.xml. Is it possible you've turned off
autogeneration of indexes in your appengine-web.xml?

http://code.google.com/appengine/docs/java/config/indexconfig.html

Jeff

pac

unread,
Jun 8, 2010, 4:42:10 PM6/8/10
to objectify-appengine
No, I did not turn off the indexes. Actually using default
configuration, so I don't have datastore-indexes.xml, in the WEB-INF/
directory,
It is creating datastore-indexes-auto.xml in WEB-INF/appengine-
generated/ directory every time I run. Only issue is that it is not
adding any index for this case.
I guess application should have failed as well if custom index needed
and it was not there.
Could be the reason that objectify first retrieves all result for
country and then filter on city i.e.
q.filter("country", "somecountry").filter("city", "somecity")

thatswhy may be it does not need any index. Is thats the case?
thanks.

On Jun 8, 5:29 pm, Jeff Schnitzer <j...@infohazard.org> wrote:
> That should work.  When I issue filters like this I get an updated
> datastore-indexs-auto.xml.  Is it possible you've turned off
> autogeneration of indexes in your appengine-web.xml?
>
> http://code.google.com/appengine/docs/java/config/indexconfig.html
>
> Jeff
>

Jeff Schnitzer

unread,
Jun 8, 2010, 4:48:30 PM6/8/10
to objectify...@googlegroups.com
No, Objectify doesn't actually do any heavy lifting in queries. It
just passes on the query parameters to the low-level API.

Upon further thought, this looks like one of those cases where GAE
does a zig-zag query using the two separate indexes. You don't need a
custom index.

Jeff

pac

unread,
Jun 8, 2010, 4:59:42 PM6/8/10
to objectify-appengine
ok, I guess it means I am using it in a right way, thanks Jeff for
clearing.

On Jun 8, 9:48 pm, Jeff Schnitzer <j...@infohazard.org> wrote:
> No, Objectify doesn't actually do any heavy lifting in queries.  It
> just passes on the query parameters to the low-level API.
>
> Upon further thought, this looks like one of those cases where GAE
> does a zig-zag query using the two separate indexes.  You don't need a
> custom index.
>
> Jeff
>
Reply all
Reply to author
Forward
0 new messages