You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, liveSearchStyle has two options.
contains: contains exact phrase, case insensitive
startsWith: starts with exact phrase, case insensitive
The project we are working has had demands increased to have this option
'containsAllWords'
In short, it would take the phrase entered by the user and explode it on spaces. Then it would look for things that contain all of the words.
Specifically there is a large list of products in a format often like this [MODEL] [SIZE] [ATTRIBUTES] [PRODUCT TYPE]
Model would have things like QG-65, QG-80, etc
Attributes would have things like: ROUND, SQUARE, SMOOTH, SERRATED
Ideally what would happen is that the end-user would search for
QG-80 SQUARE. And it would bring up options that include both "QG-80" and "SQUARE".
I have included an updated stringSearch as an example of we accomplished it.
functionstringSearch(li,searchString,method,normalize){varstringTypes=['display','subtext','tokens'],searchSuccess=false,multiSuccess=false,multiFail=false;varkeywords=searchString.split(" ");for(vari=0;i<stringTypes.length;i++){varstringType=stringTypes[i],string=li[stringType];if(string){string=string.toString();// Strip HTML tags. This isn't perfect, but it's much faster than any other methodif(stringType==='display'){string=string.replace(/<[^>]+>/g,'');}if(normalize)string=normalizeToBase(string);string=string.toUpperCase();console.log(method);if(method==='contains'){searchSuccess=string.indexOf(searchString)>=0;}elseif(method==='containsAllWords'){//Searches within the stringType for all words. If All words are found, returns true.multiSuccess=false;multiFail=false;keywords.forEach(function(item,index){if(string.indexOf(item)>=0){multiSuccess=true;}else{multiFail=true;}});if(multiSuccess&&!multiFail)searchSuccess=true;}else{searchSuccess=string.startsWith(searchString);}if(searchSuccess)break;}}returnsearchSuccess;}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently, liveSearchStyle has two options.
contains: contains exact phrase, case insensitive
startsWith: starts with exact phrase, case insensitive
The project we are working has had demands increased to have this option
'containsAllWords'
In short, it would take the phrase entered by the user and explode it on spaces. Then it would look for things that contain all of the words.
Specifically there is a large list of products in a format often like this
[MODEL] [SIZE] [ATTRIBUTES] [PRODUCT TYPE]
Model would have things like QG-65, QG-80, etc
Attributes would have things like: ROUND, SQUARE, SMOOTH, SERRATED
Ideally what would happen is that the end-user would search for
QG-80 SQUARE. And it would bring up options that include both "QG-80" and "SQUARE".
I have included an updated stringSearch as an example of we accomplished it.
Beta Was this translation helpful? Give feedback.
All reactions