Fix stemmer stripping hyphens instead of splitting on them
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user