search: factor out text parameter creation
Created by: rvantonder
Stacked on https://github.com/sourcegraph/sourcegraph/pull/31598.
Need to factor this out so I can reuse it to create an optimized search job. Also useful because in theory this is a chunk of the spaghetti logic that we should simplify/reduce over time.
Test plan
Semantics-preserving