SmartSearch with search term using starts with

Jeff Torririt asked on January 23, 2019 22:21

Is there a way to create smartsearch index that when you applied search term it will search via starts with.

Example, when I search using product name, it will only show products with name starting with the term I used.

Recent Answers


Peter Mogilnitski answered on January 24, 2019 00:49 (last edited on January 24, 2019 00:57)

You are looking for wild card functionality. Yes you can, it is built in lucene I.e smart search. So if you search for test* it should bring you testing. If it doesn't work than your tokenizer type is not the right one. You will need to experiment here.

0 votesVote for this answer Mark as a Correct answer

Jeff Torririt answered on January 24, 2019 00:56

Hi Peter,

Do you mean the field should be tokenized? Sorry, I'm not yet familiar with other terms

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on January 24, 2019 04:26 (last edited on January 24, 2019 05:24)

Sorry I meant anylizer type. I tried with standard analyzer on my default index - it seems working. Go to your index, click on preview tab and try there. it even works here: if you type in the search box on top of this site - test* you will that it is working :)

0 votesVote for this answer Mark as a Correct answer

Eric Dugre answered on January 24, 2019 15:36

As Peter mentioned, you can use Lucene syntax out-of-the-box to search using a "starts with" functionality. This works best if you are performing a field-specific search or if your visitors know to add the "*" to the search.

You could also change the analyzer to "Starts with": https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/configuring-search-assistance-features-for-local-indexes#Configuringsearchassistancefeaturesforlocalindexes-Substringsearch. This will tokenize all fields marked Tokenize into substrings allowing for a "starts with" functionality for all fields without the use of the "*" character.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.