From 647ee46edff789634a34dc0a406d19d8a50f21cd Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Fri, 7 Oct 2016 12:40:57 +1100 Subject: [PATCH] FIX: don't stem the search term Search for "canned" not working correctly and "butted", "ands" and many more :) --- lib/search.rb | 2 +- spec/components/search_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/search.rb b/lib/search.rb index be4beb5a5e0..e9f3cddc16f 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -663,7 +663,7 @@ class Search def self.ts_query(term, locale = nil, joiner = "&") data = Post.exec_sql("SELECT to_tsvector(:locale, :term)", - locale: locale || long_locale, + locale: 'simple', term: term ).values[0][0] diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb index 23d29ea53e9..20c2046e0b0 100644 --- a/spec/components/search_spec.rb +++ b/spec/components/search_spec.rb @@ -323,6 +323,11 @@ describe Search do end end + it 'does not tokenize search term' do + Fabricate(:post, raw: 'thing is canned should still be found!') + expect(Search.execute('canned').posts).to be_present + end + context 'categories' do let!(:category) { Fabricate(:category) }