aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-06-24 16:08:32 +0100
committerGareth Rees <gareth@mysociety.org>2014-06-25 10:40:38 +0100
commitf23b89f3474847cdd14ba892c5a7259964e18148 (patch)
tree2cf1440df2e9e8aeecd47ac2b25ec4f683bf0d6d /spec/models
parente490c4a7ec7157e794d849c962371e298d8342d9 (diff)
Handle unhelpful stemming
Stemming returns 'bore' as the word to highlight which can't be matched in the original phrase. Also removes duplicates from the results
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/xapian_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb
index 4230a63cd..678e3a2dc 100644
--- a/spec/models/xapian_spec.rb
+++ b/spec/models/xapian_spec.rb
@@ -413,6 +413,16 @@ describe ActsAsXapian::Search, "#words_to_highlight" do
s.words_to_highlight.should == ["depart", "humpadinking"]
end
+ it "includes the original search terms if requested" do
+ s = ActsAsXapian::Search.new([PublicBody], 'boring', :limit => 1)
+ s.words_to_highlight(:include_original => true).should == ['bore', 'boring']
+ end
+
+ it "does not return duplicate terms" do
+ s = ActsAsXapian::Search.new([PublicBody], 'boring boring', :limit => 1)
+ s.words_to_highlight.should == ['bore']
+ end
+
context 'the :regex option' do
it 'wraps each words in a regex that matches the full word' do