Always return QueryResults from map and filter (1.8 backport)

Fixes #17681

(cherry picked from commit bdd52aceb1319e919aa8a5157156c36170bcc098)