use args or captures to pick search terms on 404

Rather than cutting off two path segments and using the rest to pick
suggested search terms, use all of the arguments or captures from the
last action.

Fixes #1248.