vendrhub / vendr-demo-store

Demo store for Vendr, the eCommerce solution for Umbraco v8+
MIT License
25 stars 15 forks source link

Search throw ysod when search term contains hyphen #7

Open bjarnef opened 4 years ago

bjarnef commented 4 years ago

In demo store the following product exists: https://try.vendr.net/products/joes-tea-and-co/whiter-than-white/

The product can be found when searching for "Joes Tea" and "Joes Tea Co", but not "Joes Tea and Co" (this contains the stopword "and").

Furthermore when searching for "Joes Tea and Co - Whiter Than White" it throw an ysod, where the url shows the following: https://try.vendr.net/search/?q=Joes+Tea+and+Co+-+Whiter+Than+White It seems to be because of the hyphen (-).

image

bjarnef commented 4 years ago

We have also noticed the default search in demo store doesn't search for the Danish characters æøå, where it seems it behind the scenes would expect ae, o and a instead.

When searching on words (which included these characters) from Examine management dashboard it did seem to find these results. I guess it is because it is using Search() when not specifying a lucene query: https://github.com/umbraco/Umbraco-CMS/blob/v8/contrib/src/Umbraco.Web/Editors/ExamineManagementController.cs#L69-L71

On a project we used the following https://gist.github.com/ismailmayat/83715613236db7ae8742a180f8d3abed https://our.umbraco.com/forum/umbraco-8/98625-examine-with-swedish-characters

On another project, where the search is more or less as in demo store, it didn't seem to fix this issue, but the following did however seem to return more results than the default search.

var searcher = (BaseLuceneSearcher)index.GetSearcher();

var asciiFilter = new AsciiFoldingFilter(searcher);
q = asciiFilter.FlattenToAscii(q);

var searchTerms = Tokenize(q);

I also found this which might be helpful: https://stackoverflow.com/questions/31547585/ignore-special-characters-tittles-in-examine-search