Skip to content

Commit

Permalink
Treat unstemmed words as normal search terms.
Browse files Browse the repository at this point in the history
has_normal_search_terms? was only returning true if the query had a
stemmed search term in it, such as Zterm. Searching for a word with
capital letters, such as NHS, translates to an unstemmed query term
“nhs”. This would not match and the search would default to sorting
by newest rather than relevance. Unstemmed query terms should still
match as a normal search term, not a prefixed one.
  • Loading branch information
dracos committed Jan 23, 2024
1 parent 1446f26 commit 8b63a76
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/acts_as_xapian/acts_as_xapian.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,9 @@ def has_normal_search_terms?
#x = ''
query.terms.each do |t|
term = t.term
#x = x + term.to_yaml + term.size.to_s + term[0..0] + "*"
if term.size >= 2 && term[0..0] == 'Z'
# normal terms begin Z (for stemmed), then have no capital letter prefix
ret = true if term[1..1] == term[1..1].downcase
# normal terms begin Z (for stemmed), or have no capital letter prefix
if term.size >= 1 && (term[0..0] == 'Z' || term[0..0] == term[0..0].downcase)

Check warning on line 415 in lib/acts_as_xapian/acts_as_xapian.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Line is too long. [85/80] (https://rubystyle.guide#max-line-length) Raw Output: lib/acts_as_xapian/acts_as_xapian.rb:415:81: C: Layout/LineLength: Line is too long. [85/80] (https://rubystyle.guide#max-line-length)
ret = true
end
end
ret
Expand Down

0 comments on commit 8b63a76

Please sign in to comment.