The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Blocking wildcard * at the beginning of a query in typeahead using a regexp (Istanbul)

Alexandre Sing2
Kilo Expert

Hello,

We are facing big issues with (*)+keyword queries on typeahead search. (wildcard at the beginning of a word)

The platform can't handle it, you can wait a very long time before erratic results appear.

This may be corrected in Kingston but this customer is still on Istanbul and is complaining.

I am investigating a way to block end-user query submission and/or just remove the stars from their query

Problem is I don't use regexps everyday, so I am having a really hard time building this regexp : 

"OK for anything except a star at the beginning of your search query" : *key-word is invalid, key*word is.

Anyone has a solution please ? or if you have been facing this issue, and have a solution ?

Thank you very much.

Best Regards,

 

1 ACCEPTED SOLUTION

Olyn Dabbs
Giga Expert

Hi Karim,


I believe the correct regex would be ^[^\*].+$ 

 

The above sequence will allow any collection of characters that doesn't begin with *.

View solution in original post

4 REPLIES 4

Olyn Dabbs
Giga Expert

Hi Karim,


I believe the correct regex would be ^[^\*].+$ 

 

The above sequence will allow any collection of characters that doesn't begin with *.

Alexandre Sing2
Kilo Expert

Thanks Olyn,

 

I had to do it otherwise : 

 

adding "while (data.q.indexOf("*") == 0) data.q = data.q.substring(1);" in typeahead search, search nav and search page's server scripts.

this could be the workaround for the PRB

 

With the regexp, we could have a warning for the user in the typeahead field, using ng-pattern = "/^[^\*].+$ /" for the input's ng-model, to add the ng-invalid class to the input, and color the field in red for .ng-invalid.

Thanks a lot, may show useful in the future.

Best Regards,

 

Hey Karim,

 

Glad you were able to figure out a solution that worked for you.  That sounds like a solid workaround.

 

Best,

 

Olyn

Alexandre Sing2
Kilo Expert

Thanks ! 

 

"%" was an issue too, so :

data.q = $sp.getParameter('q');

//then we get rid of wildcards
while (data.q.indexOf("*") == 0 || data.q.indexOf("%") == 0) data.q = data.q.substring(1);