554182f4b4
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>
14 lines
250 B
Ruby
14 lines
250 B
Ruby
module Search::Stemmer
|
|
extend self
|
|
|
|
STEMMER = Mittens::Stemmer.new
|
|
|
|
def stem(value)
|
|
if value.present?
|
|
value.gsub(/[^\w\s]/, " ").split(/\s+/).map { |word| STEMMER.stem(word.downcase) }.join(" ")
|
|
else
|
|
value
|
|
end
|
|
end
|
|
end
|