When I read your original post, my first thought was an example on Public I had seen
but I suspect (haven't checked) that's its not quite as complex as you need, but maybe has some useful techniques/tools
Certainly for string functions (which you will need!!) - this blog post is very good
I have experience with a similar task, but I have to admit, for that we used ElasticSearch
Here with some alternative progams
Hoping here something is helpful, keen to hear from others...