search: factor out getPatternInfo into pure function
Created by: keegancsmith
This allows us to more easily use it in other contexts. Most importantly in tests we can now more succinctly define input data via just the query string, rather than by also creating the TextPatternInfo.