Magento 2 - 如果只有一个结果,则重定向搜索

I'm trying to custom the default Magento 2 search engine. I would like to automatically redirects to the product page when search returns only one result. I tried to override the Result/Index controller but nothings worked.

Thanks for your help !

You need to use the configuration, no need to devellop anything additionnal. Here is a link to a good resource : https://www.magestore.com/magento-2-tutorial/how-to-manage-search-term-in-magento-2/

If you really need to redirect programmatically, I advise you to use dependency injection more than override.

This is a native feature of ElasticSuite : https://github.com/Smile-SA/elasticsuite

Maybe should you give a try at the extension.

Disclosure : I am the lead developper of ElasticSuite