Optional Characters in smart search

Chris Bass asked on November 15, 2018 17:13

So, similar to this person:
https://devnet.kentico.com/questions/smart-search-index-with-character-in-conrtent

I've got a client that has data like 'AB-123' in their pages. Subset search will allow things like 'AB' or 'B-12' to return results, but here's the trick: They want those to work, but also want 'B12' or 'AB123' to be valid search terms to retrieve this page. Specifically, they want hyphens to be 'optional' search items.

Is what I need to do here to create a custom indexer, that strips out hyphens, and a custom analyzer that also strips out hyphens from the middle of search terms? How hard are those to create?
I also considered a custom indexer that just indexes both versions - hyphened and hyphenless, but then doing a quoted exact string wouldn't work.
Just looking for whether I'm missing anything, like a reason this wouldn't work like I expect, or if there's a third option.

Recent Answers


Rui Wang answered on November 15, 2018 17:32

Have they considered add "AB123" as a metadata keyword to the page, so subset search will automatically work for "B12" without any customization?

0 votesVote for this answer Mark as a Correct answer

Chris Bass answered on November 15, 2018 18:01

A good idea, but this site has a metric ton of products, I'd essentially have to write a scheduled task (or global event on document update) to scan the properties for those sorts of hyphened IDs and add them to the keywords.

0 votesVote for this answer Mark as a Correct answer

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