Dear Ashma,
The Wellcome search within implementation is powered by ALTO, but not by Elasticsearch or Solr. It is fairly simplistic and builds a map of word coordinates in ALTO to generate annotations dynamically. The code is in C# and not separated out into a clean module, but I could send it to you if you are interested.
Another approach is to convert the ALTO to hOCR so that it can be used with ocracoke:
We are actually working right now on an Elasticsearch powered IIIF Content Search API (wrapped in Python this time), I'll ask one of my colleagues to chip in here with some details.
Tom