elastic_record 0.9.1 → 0.9.2
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.
data/elastic_record.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'elastic_record'
|
5
|
-
s.version = '0.9.
|
5
|
+
s.version = '0.9.2'
|
6
6
|
s.summary = 'Use Elastic Search with your objects'
|
7
7
|
s.description = 'Find your records with elastic search'
|
8
8
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.author = 'Matthew Higgins'
|
14
14
|
s.email = 'developer@matthewhiggins.com'
|
15
|
-
s.homepage = 'http://github.com/
|
15
|
+
s.homepage = 'http://github.com/infogroup/elastic_record'
|
16
16
|
|
17
17
|
s.extra_rdoc_files = ['README.rdoc']
|
18
18
|
s.files = `git ls-files`.split("\n")
|
@@ -30,21 +30,22 @@ module ElasticRecord
|
|
30
30
|
end.join(' AND ')
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
word
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
def match_word(word, fields, &block)
|
36
|
+
if word =~ / / || word =~ ESCAPE_REGEX
|
37
|
+
word = "\"#{word}\""
|
38
|
+
else
|
39
|
+
word = "#{word}*"
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
or_query = fields.map do |field|
|
43
|
+
field = yield(field) if block_given?
|
44
|
+
"#{field}:#{word}"
|
45
|
+
end.join(' OR ')
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
"(#{or_query})"
|
48
|
+
end
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -11,6 +11,7 @@ class ElasticRecord::LuceneTest < MiniTest::Spec
|
|
11
11
|
assert_smart_escape nil, nil, ['name']
|
12
12
|
|
13
13
|
assert_smart_escape '(name:foo*)', 'foo', ['name']
|
14
|
+
assert_smart_escape '(name:"foo-bar")', 'foo-bar', ['name']
|
14
15
|
assert_smart_escape "(name:bob's*)", "bob's", ['name']
|
15
16
|
assert_smart_escape '(name.analyzed:foo*)', 'foo', ['name'] { |f| "#{f}.analyzed" }
|
16
17
|
assert_smart_escape '(name:foo* OR street:foo*)', 'foo', ['name', 'street']
|
@@ -62,4 +62,15 @@ class ElasticRecord::SearchesManyTest < MiniTest::Spec
|
|
62
62
|
assert_equal "blue", widgets.first.color
|
63
63
|
assert_equal "Toy", widgets.first.name
|
64
64
|
end
|
65
|
+
|
66
|
+
def test_reload
|
67
|
+
warehouse = Warehouse.create
|
68
|
+
widget = Widget.create name: 'Toy', color: 'green', warehouse: warehouse
|
69
|
+
assert_equal [widget], warehouse.widgets
|
70
|
+
widget.destroy
|
71
|
+
|
72
|
+
warehouse.reload
|
73
|
+
|
74
|
+
assert_equal [], warehouse.widgets
|
75
|
+
end
|
65
76
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
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: 2012-
|
12
|
+
date: 2012-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: arelastic
|
@@ -116,7 +116,7 @@ files:
|
|
116
116
|
- test/support/models/test_model.rb
|
117
117
|
- test/support/models/warehouse.rb
|
118
118
|
- test/support/models/widget.rb
|
119
|
-
homepage: http://github.com/
|
119
|
+
homepage: http://github.com/infogroup/elastic_record
|
120
120
|
licenses:
|
121
121
|
- MIT
|
122
122
|
post_install_message:
|