Using query (ndb) instead of filter (db). Fixes bug.

Reviewed in https://codereview.appspot.com/10392046/