The haystack idea reminds me of this wonderful post from the creator of both the Rust regex crate and the ripgrep command line utility (among other awesome things).
Also discussed only 1 year ago:
https://news.ycombinator.com/item?id=28243636 (174 points, 10 comments)