From 554182f4b4ef5348441f88e900a15315459193b4 Mon Sep 17 00:00:00 2001 From: Fernando Olivares Date: Thu, 19 Feb 2026 16:16:39 -0600 Subject: [PATCH] Fix stemmer stripping hyphens instead of splitting on them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stemmer was concatenating tokens across hyphens (e.g. "BC3-IOS-1D8B" → "bc3ios1d8b") while the query sanitizer split on them, causing MySQL MATCH AGAINST to never find the indexed token. Replace non-word chars with spaces instead of stripping them so indexing and querying tokenize consistently. Requires search:reindex after deploy to rebuild existing search records. Co-Authored-By: Claude Opus 4.6 --- app/models/search/stemmer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/search/stemmer.rb b/app/models/search/stemmer.rb index f6a6c56d4..21cb75f97 100644 --- a/app/models/search/stemmer.rb +++ b/app/models/search/stemmer.rb @@ -5,7 +5,7 @@ module Search::Stemmer def stem(value) if value.present? - value.gsub(/[^\w\s]/, "").split(/\s+/).map { |word| STEMMER.stem(word.downcase) }.join(" ") + value.gsub(/[^\w\s]/, " ").split(/\s+/).map { |word| STEMMER.stem(word.downcase) }.join(" ") else value end