I'm trying to select a 255 characters max from a text and returns only the substring containing the matched words a user is looking for or the first one.
This is a script for a search engine in my site where results preview only posts containing the set of words the user is searching.
Here is an example for a preview:
A user type in search box "manufacturing companies"
...visited the campus to announce the creation of a new public-private **Manufacturing** Innovation Institute that will soon take up residence at NC State. Eighteen **companies** headquartered in North Carolina will partner...
In case there are more coincidences, select only the substring that contains more words matched.
How can I accomplish this within a query?
Thanks.