Upgrade to Magento 2.4.1 from 2.3.1 was successful. However, I find the following error message on running upgrade command. If one can enable/install elasticsearch as search engine now, please guide me as to what needs to be done.
If you don't have access to your admin dashboard post upgrading, you can use the CLI to set it up using
php bin/magento config:set catalog/search/engine 'elasticsearch7'
Instead of elasticsearch7 you might use elasticsearch5, or elasticsearch6 depending on your current version of elasticsearch. Hope it helps!
Please refer to the official documentation for troubleshooting this error, as your installation might be in an inconsistent state.
Please also be careful that in Magento 2.4.x, you no longer have support for Elasticsearch 5.x or 6.x, so running any CLI commands that refer those engines won't help you. The correct version is Elasticsearch 7.x (you should know that Magento 2.4.x was tested with Elasticsearch 7.6.x only, in case you choose another 7.x version).
Once you followed the steps from the official documentation mentioned above you should have correct access to the admin so you can setup the search engine.
But, if you need the CLI commands succession to enable the search engine, it's something like this:
php bin/magento config:set catalog/search/engine elasticsearch7 php bin/magento config:set catalog/search/elasticsearch7_server_hostname <elasticsearch_hostname> php bin/magento config:set catalog/search/elasticsearch7_server_port <elasticsearch_port>
Please make sure you are replacing the hostname and port placeholders with your actual connection to Elasticsearch data.