mongoid_fulltext 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.5
1
+ 0.5.6
@@ -24,7 +24,7 @@ module Mongoid::FullTextSearch
24
24
 
25
25
  config = {
26
26
  :alphabet => 'abcdefghijklmnopqrstuvwxyz0123456789 ',
27
- :word_separators => "- \n\t",
27
+ :word_separators => "-_ \n\t",
28
28
  :ngram_width => 3,
29
29
  :max_ngrams_to_search => 6,
30
30
  :apply_prefix_scoring_to_all_words => true,
@@ -189,8 +189,8 @@ module Mongoid::FullTextSearch
189
189
  str = UnicodeUtils.nfkd(CGI.unescape(str)).gsub(/[^\x00-\x7F]/,'')
190
190
  end
191
191
 
192
- # Remove any characters that aren't in the alphabet
193
- filtered_str = str.mb_chars.to_s.downcase.split('').find_all{ |ch| config[:alphabet][ch] }.join('')
192
+ # Remove any characters that aren't in the alphabet and aren't word separators
193
+ filtered_str = str.mb_chars.to_s.downcase.split('').find_all{ |ch| config[:alphabet][ch] or config[:word_separators][ch] }.join('')
194
194
 
195
195
  # Figure out how many ngrams to extract from the string. If we can't afford to extract all ngrams,
196
196
  # step over the string in evenly spaced strides to extract ngrams. For example, to extract 3 3-letter
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid_fulltext}
8
- s.version = "0.5.5"
8
+ s.version = "0.5.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Windsor"]
@@ -410,6 +410,18 @@ module Mongoid
410
410
  end
411
411
  end
412
412
 
413
+ context "with various word separators" do
414
+ let!(:hard_edged_painting) { BasicArtwork.create(:title => "Hard-edged painting") }
415
+ let!(:edgy_painting) { BasicArtwork.create(:title => "Edgy painting") }
416
+ let!(:hard_to_find_ledge) { BasicArtwork.create(:title => "Hard to find ledge") }
417
+
418
+ it "should treat dashes as word separators, giving a score boost to each dash-separated word" do
419
+ BasicArtwork.fulltext_search('hard-edged').first.should == hard_edged_painting
420
+ BasicArtwork.fulltext_search('hard edge').first.should == hard_edged_painting
421
+ BasicArtwork.fulltext_search('hard edged').first.should == hard_edged_painting
422
+ end
423
+ end
424
+
413
425
  context "returning scores" do
414
426
  # Since we return scores, let's make some weak guarantees about what they actually mean
415
427
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_fulltext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: unicode_utils
17
- requirement: &74785740 !ruby/object:Gem::Requirement
17
+ requirement: &79305610 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 1.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *74785740
25
+ version_requirements: *79305610
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: mongoid
28
- requirement: &74785500 !ruby/object:Gem::Requirement
28
+ requirement: &79305370 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *74785500
36
+ version_requirements: *79305370
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bson_ext
39
- requirement: &74785260 !ruby/object:Gem::Requirement
39
+ requirement: &79305130 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.3.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *74785260
47
+ version_requirements: *79305130
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &74785020 !ruby/object:Gem::Requirement
50
+ requirement: &79304890 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 2.5.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *74785020
58
+ version_requirements: *79304890
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: jeweler
61
- requirement: &74784780 !ruby/object:Gem::Requirement
61
+ requirement: &79304650 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: 1.5.2
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *74784780
69
+ version_requirements: *79304650
70
70
  description: Full-text search for the Mongoid ORM, using n-grams extracted from text
71
71
  email: aaron.windsor@gmail.com
72
72
  executables: []
@@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  segments:
122
122
  - 0
123
- hash: -329929775
123
+ hash: 465387827
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  none: false
126
126
  requirements: