So I wrote a little function that iterates over the searchable text (in this case it was full names and user names) and adds each fragment/token to a collection and then did a match on that collection in the query. Anything the user might type to find the thing has to go in that child object so you have to tokenise to give yourself every version of what they will be searching as they type.
So my name would go in as
S
Si
Sim
Simo
Simon
Simonb
Simonbar
Simonbark
Simonbarke
Simonbarker
B
Ba
Bar
Bark
Barke
Barker
Etc
Etc
Failing that just dump everything in to an elastic search instance and call out to that for search. It’s not too hard to keep and ES in sync but it’s also more expensive sadly
So my name would go in as S Si Sim Simo Simon Simonb Simonbar Simonbark Simonbarke Simonbarker B Ba Bar Bark Barke Barker Etc Etc
Failing that just dump everything in to an elastic search instance and call out to that for search. It’s not too hard to keep and ES in sync but it’s also more expensive sadly