Best practices to handle invalid Syntax when using Coveo for Sitecore
If a user enters specific Coveo operators in the search box, it will return an error. For example, searching for only * or + returns:
No results found for * Not enough leading characters for the wildcard expression '*'. Specify at least 2 leading characters.
No results found for + Invalid query syntax ('+').
This is an expected behavior since the error is returned by CES Index itself. My question, what would be the best method to intercept these errors from an OTB Coveo for Sitecore search page
- A feature on the Search Page itself or in the JS Ui Framework?
- A query Processor at the Coveo for Sitecore Level?
- A query Pipeline at the REST API Level?
What are your recommendation on how to alter the experience for a user that searches for just * so they get back all search results?
I would suggest to handle this kind of error in the client code (using the JS UI Framework). Adding an handler on the
queryError event would allow to catch the error and issue the default query when needed. Be careful to issue a new query only for the errors caused by the user query otherwise you can end up with an infinite loop.
For more information on how to handle JS UI events and how to issue new queries, see:
- Coveo for Sitecore 3.0 (uses JS UI 0.9) :
- Coveo for Sitecore 4.0 (uses JS UI 1.0) :