fulltext_searchable 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ require 'digest/md5'
|
|
7
7
|
# 全文検索インデックスとして機能するモデル。
|
8
8
|
#
|
9
9
|
class FulltextIndex < ActiveRecord::Base
|
10
|
+
BOOLEAN_META_CHARACTER_REGEXP = /^[\+\-><\(\)~*"]*/
|
10
11
|
self.table_name = FulltextSearchable::TABLE_NAME
|
11
12
|
self.primary_key = :_id
|
12
13
|
after_create :set_grn_insert_id
|
@@ -37,6 +38,7 @@ class FulltextIndex < ActiveRecord::Base
|
|
37
38
|
if phrase.is_a? String
|
38
39
|
phrase = phrase.split(/[\s ]/).reject{|word| word.blank? }
|
39
40
|
end
|
41
|
+
phrase.map!{|word| word.gsub(BOOLEAN_META_CHARACTER_REGEXP, '')}
|
40
42
|
|
41
43
|
# モデルで絞り込む
|
42
44
|
model_keywords = []
|
@@ -89,6 +89,14 @@ describe FulltextIndex do
|
|
89
89
|
FulltextIndex.match('営業 状態').items.count.should == 2
|
90
90
|
FulltextIndex.match(" 営業\t状態 ").items.count.should == 2
|
91
91
|
end
|
92
|
+
|
93
|
+
it "should ignore special characters and not break when meta characters are passed" do
|
94
|
+
"+-><()~*\"".split(//).each do |character|
|
95
|
+
FulltextIndex.match(character + '太郎', :model => User).items.count.should == 1
|
96
|
+
end
|
97
|
+
FulltextIndex.match('++太郎', :model => User).items.count.should == 1
|
98
|
+
FulltextIndex.match(['+太郎'], :model => User).items.count.should == 1
|
99
|
+
end
|
92
100
|
end
|
93
101
|
|
94
102
|
context "optimization" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fulltext_searchable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -298,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
298
298
|
version: '0'
|
299
299
|
segments:
|
300
300
|
- 0
|
301
|
-
hash: -
|
301
|
+
hash: -3155726735639838905
|
302
302
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
303
303
|
none: false
|
304
304
|
requirements:
|
@@ -307,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
307
|
version: '0'
|
308
308
|
segments:
|
309
309
|
- 0
|
310
|
-
hash: -
|
310
|
+
hash: -3155726735639838905
|
311
311
|
requirements: []
|
312
312
|
rubyforge_project:
|
313
313
|
rubygems_version: 1.8.25
|