I am trying to override the
search query when loading the search results page. For example: the user enters "Gren Aple", and my script fixes syntax/spelling errors and loads the page with the result of "Green Apple".
I will be glad to any help.
I can suggest installing and enabling elasticSearch. It's a great feature, some more information here: http://devdocs.magento.com/guides/v2.1/config-guide/elasticsearch/es-overview.html
Suggest you to give a try at Elasticsuite : https://github.com/Smile-SA/elasticsuite