Namespaced searching

The second commit message contains the details.

Also included is something that should have been handled in the deploy->apply commit, but slipped through.  This is even though it made tests fail---another reason either for me to be more careful, reviewers to run tests themselves (we should put up a description of how to do this easily), or to have the unit tests run in an automated fashion somehow.

This is a mess.  Look at the result, not the diff.  Focus especially on the helper function, to see the functional changes I made.
Factor this query into a separate helper function.