sunspot 2.2.7 → 2.2.8
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/Appraisals +7 -0
- data/Gemfile +0 -8
- data/gemfiles/.gitkeep +0 -0
- data/lib/sunspot/dsl/scope.rb +6 -1
- data/lib/sunspot/field.rb +11 -0
- data/lib/sunspot/field_factory.rb +6 -2
- data/lib/sunspot/query/bbox.rb +5 -1
- data/lib/sunspot/query/restriction.rb +11 -0
- data/lib/sunspot/search/hit_enumerable.rb +4 -1
- data/lib/sunspot/search/standard_search.rb +2 -3
- data/lib/sunspot/version.rb +1 -1
- data/spec/api/adapters_spec.rb +19 -19
- data/spec/api/batcher_spec.rb +15 -15
- data/spec/api/binding_spec.rb +3 -3
- data/spec/api/class_set_spec.rb +3 -3
- data/spec/api/hit_enumerable_spec.rb +32 -9
- data/spec/api/indexer/attributes_spec.rb +31 -31
- data/spec/api/indexer/batch_spec.rb +8 -7
- data/spec/api/indexer/dynamic_fields_spec.rb +8 -8
- data/spec/api/indexer/fixed_fields_spec.rb +12 -12
- data/spec/api/indexer/fulltext_spec.rb +8 -8
- data/spec/api/indexer/removal_spec.rb +14 -14
- data/spec/api/indexer_spec.rb +2 -2
- data/spec/api/query/advanced_manipulation_examples.rb +3 -3
- data/spec/api/query/connectives_examples.rb +26 -14
- data/spec/api/query/dsl_spec.rb +17 -9
- data/spec/api/query/dynamic_fields_examples.rb +18 -18
- data/spec/api/query/faceting_examples.rb +62 -62
- data/spec/api/query/fulltext_examples.rb +56 -55
- data/spec/api/query/function_spec.rb +26 -26
- data/spec/api/query/geo_examples.rb +6 -6
- data/spec/api/query/group_spec.rb +6 -6
- data/spec/api/query/highlighting_examples.rb +26 -26
- data/spec/api/query/join_spec.rb +2 -2
- data/spec/api/query/more_like_this_spec.rb +29 -29
- data/spec/api/query/ordering_pagination_examples.rb +25 -25
- data/spec/api/query/scope_examples.rb +39 -39
- data/spec/api/query/spatial_examples.rb +3 -3
- data/spec/api/query/spellcheck_examples.rb +3 -3
- data/spec/api/query/standard_spec.rb +1 -1
- data/spec/api/query/stats_examples.rb +8 -8
- data/spec/api/query/text_field_scoping_examples.rb +5 -5
- data/spec/api/query/types_spec.rb +4 -4
- data/spec/api/search/cursor_paginated_collection_spec.rb +12 -12
- data/spec/api/search/dynamic_fields_spec.rb +4 -4
- data/spec/api/search/faceting_spec.rb +55 -52
- data/spec/api/search/highlighting_spec.rb +7 -7
- data/spec/api/search/hits_spec.rb +29 -29
- data/spec/api/search/paginated_collection_spec.rb +18 -18
- data/spec/api/search/results_spec.rb +13 -13
- data/spec/api/search/search_spec.rb +3 -3
- data/spec/api/search/stats_spec.rb +10 -10
- data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +19 -18
- data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +9 -9
- data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +10 -6
- data/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb +10 -10
- data/spec/api/session_proxy/sharding_session_proxy_spec.rb +14 -13
- data/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +2 -2
- data/spec/api/session_proxy/spec_helper.rb +1 -1
- data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +9 -5
- data/spec/api/session_spec.rb +42 -42
- data/spec/api/sunspot_spec.rb +4 -4
- data/spec/integration/atomic_updates_spec.rb +25 -11
- data/spec/integration/dynamic_fields_spec.rb +10 -10
- data/spec/integration/faceting_spec.rb +39 -39
- data/spec/integration/field_grouping_spec.rb +16 -16
- data/spec/integration/field_lists_spec.rb +41 -0
- data/spec/integration/geospatial_spec.rb +19 -8
- data/spec/integration/highlighting_spec.rb +5 -5
- data/spec/integration/indexing_spec.rb +5 -5
- data/spec/integration/keyword_search_spec.rb +47 -45
- data/spec/integration/local_search_spec.rb +4 -4
- data/spec/integration/more_like_this_spec.rb +7 -7
- data/spec/integration/scoped_search_spec.rb +107 -107
- data/spec/integration/spellcheck_spec.rb +52 -7
- data/spec/integration/stats_spec.rb +10 -10
- data/spec/integration/stored_fields_spec.rb +1 -1
- data/spec/integration/test_pagination.rb +4 -4
- data/spec/integration/unicode_spec.rb +1 -1
- data/spec/mocks/post.rb +5 -1
- data/spec/spec_helper.rb +11 -6
- data/sunspot.gemspec +3 -1
- metadata +40 -7
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe 'fields lists' do
|
4
|
+
before :all do
|
5
|
+
Sunspot.remove_all
|
6
|
+
@post = Post.new(title: 'A Title', body: 'A Body', featured: true, tags: ['tag'])
|
7
|
+
Sunspot.index!(@post)
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:stored_field_names) do
|
11
|
+
(Sunspot::Setup.for(Post).fields + Sunspot::Setup.for(Post).all_text_fields)
|
12
|
+
.select { |f| f.stored? }
|
13
|
+
.map { |f| f.name }
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'loads all stored fields by dafault' do
|
17
|
+
hit = Sunspot.search(Post).hits.first
|
18
|
+
|
19
|
+
stored_field_names.each do |field|
|
20
|
+
expect(hit.stored(field)).not_to be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'loads only filtered fields' do
|
25
|
+
hit = Sunspot.search(Post) { field_list(:title) }.hits.first
|
26
|
+
|
27
|
+
expect(hit.stored(:title)).to eq(@post.title)
|
28
|
+
|
29
|
+
(stored_field_names - [:title]).each do |field|
|
30
|
+
expect(hit.stored(field)).to be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'does not load any stored fields' do
|
35
|
+
hit = Sunspot.search(Post) { without_stored_fields }.hits.first
|
36
|
+
|
37
|
+
stored_field_names.each do |field|
|
38
|
+
expect(hit.stored(field)).to be_nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -15,7 +15,7 @@ describe "geospatial search" do
|
|
15
15
|
with(:coordinates_new).in_radius(32, -68, 1)
|
16
16
|
}.results
|
17
17
|
|
18
|
-
results.
|
18
|
+
expect(results).to include(@post)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "filters out posts not in the radius" do
|
@@ -23,10 +23,10 @@ describe "geospatial search" do
|
|
23
23
|
with(:coordinates_new).in_radius(33, -68, 1)
|
24
24
|
}.results
|
25
25
|
|
26
|
-
results.
|
26
|
+
expect(results).not_to include(@post)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "allows conjunction queries" do
|
29
|
+
it "allows conjunction queries with radius" do
|
30
30
|
results = Sunspot.search(Post) {
|
31
31
|
any_of do
|
32
32
|
with(:coordinates_new).in_radius(32, -68, 1)
|
@@ -34,7 +34,18 @@ describe "geospatial search" do
|
|
34
34
|
end
|
35
35
|
}.results
|
36
36
|
|
37
|
-
results.
|
37
|
+
expect(results).to include(@post)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "allows conjunction queries with bounding box" do
|
41
|
+
results = Sunspot.search(Post) {
|
42
|
+
any_of do
|
43
|
+
with(:coordinates_new).in_bounding_box([31, -69], [33, -67])
|
44
|
+
with(:coordinates_new).in_bounding_box([35, 68], [36, 69])
|
45
|
+
end
|
46
|
+
}.results
|
47
|
+
|
48
|
+
expect(results).to include(@post)
|
38
49
|
end
|
39
50
|
end
|
40
51
|
|
@@ -52,7 +63,7 @@ describe "geospatial search" do
|
|
52
63
|
with(:coordinates_new).in_bounding_box [31, -69], [33, -67]
|
53
64
|
}.results
|
54
65
|
|
55
|
-
results.
|
66
|
+
expect(results).to include(@post)
|
56
67
|
end
|
57
68
|
|
58
69
|
it "filters out posts not in the bounding box" do
|
@@ -60,7 +71,7 @@ describe "geospatial search" do
|
|
60
71
|
with(:coordinates_new).in_bounding_box [20, -70], [21, -69]
|
61
72
|
}.results
|
62
73
|
|
63
|
-
results.
|
74
|
+
expect(results).not_to include(@post)
|
64
75
|
end
|
65
76
|
end
|
66
77
|
|
@@ -82,7 +93,7 @@ describe "geospatial search" do
|
|
82
93
|
order_by_geodist(:coordinates_new, 32, -68)
|
83
94
|
}.results
|
84
95
|
|
85
|
-
results.
|
96
|
+
expect(results).to eq(@posts.reverse)
|
86
97
|
end
|
87
98
|
|
88
99
|
it "orders posts by distance descending" do
|
@@ -90,7 +101,7 @@ describe "geospatial search" do
|
|
90
101
|
order_by_geodist(:coordinates_new, 32, -68, :desc)
|
91
102
|
}.results
|
92
103
|
|
93
|
-
results.
|
104
|
+
expect(results).to eq(@posts)
|
94
105
|
end
|
95
106
|
end
|
96
107
|
end
|
@@ -11,16 +11,16 @@ describe 'keyword highlighting' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should include highlights in the results' do
|
14
|
-
@search_result.hits.first.highlights.length.
|
14
|
+
expect(@search_result.hits.first.highlights.length).to eq(1)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should return formatted highlight fragments' do
|
18
|
-
@search_result.hits.first.highlights(:body).first.format.
|
18
|
+
expect(@search_result.hits.first.highlights(:body).first.format).to eq('And the <em>fox</em> laughed')
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should be empty for non-keyword searches' do
|
22
22
|
search_result = Sunspot.search(Post){ with :blog_id, 1 }
|
23
|
-
search_result.hits.first.highlights.
|
23
|
+
expect(search_result.hits.first.highlights).to be_empty
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should process multiple keyword request on different fields with highlights correctly" do
|
@@ -35,8 +35,8 @@ describe 'keyword highlighting' do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end.to_not raise_error
|
38
|
-
search_results.results.length.
|
39
|
-
search_results.results.first.
|
38
|
+
expect(search_results.results.length).to eq(1)
|
39
|
+
expect(search_results.results.first).to eq(@posts.last)
|
40
40
|
# this one might be a Solr bug, therefore not related to Sunspot itself
|
41
41
|
# search_results.hits.first.highlights.should_not be_empty
|
42
42
|
end
|
@@ -2,23 +2,23 @@ require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
|
2
2
|
|
3
3
|
describe 'indexing' do
|
4
4
|
it 'should index non-multivalued field with newlines' do
|
5
|
-
|
5
|
+
expect do
|
6
6
|
Sunspot.index!(Post.new(:title => "A\nTitle"))
|
7
|
-
end.
|
7
|
+
end.not_to raise_error
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should correctly remove by model instance' do
|
11
11
|
post = Post.new(:title => 'test post')
|
12
12
|
Sunspot.index!(post)
|
13
13
|
Sunspot.remove!(post)
|
14
|
-
Sunspot.search(Post) { with(:title, 'test post') }.results.
|
14
|
+
expect(Sunspot.search(Post) { with(:title, 'test post') }.results).to be_empty
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should correctly delete by ID' do
|
18
18
|
post = Post.new(:title => 'test post')
|
19
19
|
Sunspot.index!(post)
|
20
20
|
Sunspot.remove_by_id!(Post, post.id)
|
21
|
-
Sunspot.search(Post) { with(:title, 'test post') }.results.
|
21
|
+
expect(Sunspot.search(Post) { with(:title, 'test post') }.results).to be_empty
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'removes documents by query' do
|
@@ -29,7 +29,7 @@ describe 'indexing' do
|
|
29
29
|
Sunspot.remove!(Post) do
|
30
30
|
with(:title, 'birds')
|
31
31
|
end
|
32
|
-
Sunspot.search(Post).
|
32
|
+
expect(Sunspot.search(Post).results.size).to eq(1)
|
33
33
|
end
|
34
34
|
|
35
35
|
|
@@ -19,8 +19,8 @@ describe 'keyword search' do
|
|
19
19
|
context 'edismax' do
|
20
20
|
it 'matches with wildcards' do
|
21
21
|
results = Sunspot.search(Post) { keywords '*oas*' }.results
|
22
|
-
[0,2].each { |i| results.
|
23
|
-
[1].each { |i| results.
|
22
|
+
[0,2].each { |i| expect(results).to include(@posts[i])}
|
23
|
+
[1].each { |i| expect(results).not_to include(@posts[i])}
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'matches multiple keywords on different fields with wildcards using subqueries' do
|
@@ -28,52 +28,52 @@ describe 'keyword search' do
|
|
28
28
|
keywords 'insuffic*',:fields=>[:title]
|
29
29
|
keywords 'win*',:fields=>[:body]
|
30
30
|
end.results
|
31
|
-
[0].each {|i| results.
|
32
|
-
[1,2].each {|i| results.
|
31
|
+
[0].each {|i| expect(results).to include(@posts[i])}
|
32
|
+
[1,2].each {|i| expect(results).not_to include(@posts[i])}
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'matches with proximity' do
|
36
36
|
results = Sunspot.search(Post) { keywords '"wind buffer"~4' }.results
|
37
|
-
[0,1].each {|i| results.
|
38
|
-
[2].each {|i| results.
|
37
|
+
[0,1].each {|i| expect(results).not_to include(@posts[i])}
|
38
|
+
[2].each {|i| expect(results).to include(@posts[i])}
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'does not match if not within proximity' do
|
42
42
|
results = Sunspot.search(Post) { keywords '"wind buffer"~1' }.results
|
43
|
-
results.
|
43
|
+
expect(results).to eq([])
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'matches a single keyword out of a single field' do
|
48
48
|
results = Sunspot.search(Post) { keywords 'toast' }.results
|
49
|
-
[0, 2].each { |i| results.
|
50
|
-
[1].each { |i| results.
|
49
|
+
[0, 2].each { |i| expect(results).to include(@posts[i]) }
|
50
|
+
[1].each { |i| expect(results).not_to include(@posts[i]) }
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'matches multiple words out of a single field' do
|
54
54
|
results = Sunspot.search(Post) { keywords 'elects toast' }.results
|
55
|
-
results.
|
55
|
+
expect(results).to eq([@posts[0]])
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'matches multiple words in multiple fields' do
|
59
59
|
results = Sunspot.search(Post) { keywords 'toast wind' }.results
|
60
|
-
[0, 2].each { |i| results.
|
61
|
-
[1].each { |i| results.
|
60
|
+
[0, 2].each { |i| expect(results).to include(@posts[i]) }
|
61
|
+
[1].each { |i| expect(results).not_to include(@posts[i]) }
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'matches multiple types' do
|
65
65
|
results = Sunspot.search(Post, Namespaced::Comment) do
|
66
66
|
keywords 'toast'
|
67
67
|
end.results
|
68
|
-
[@posts[0], @posts[2], @comment].each { |obj| results.
|
69
|
-
results.
|
68
|
+
[@posts[0], @posts[2], @comment].each { |obj| expect(results).to include(obj) }
|
69
|
+
expect(results).not_to include(@posts[1])
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'matches keywords from only the fields specified' do
|
73
73
|
results = Sunspot.search(Post) do
|
74
74
|
keywords 'moron', :fields => [:title]
|
75
75
|
end.results
|
76
|
-
results.
|
76
|
+
expect(results).to eq([@posts[1]])
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'matches multiple keywords on different fields using subqueries' do
|
@@ -81,13 +81,13 @@ describe 'keyword search' do
|
|
81
81
|
keywords 'moron', :fields => [:title]
|
82
82
|
keywords 'wind', :fields => [:body]
|
83
83
|
end
|
84
|
-
search.results.
|
84
|
+
expect(search.results).to eq([])
|
85
85
|
|
86
86
|
search = Sunspot.search(Post) do
|
87
87
|
keywords 'moron', :fields => [:title]
|
88
88
|
keywords 'buffer', :fields => [:body]
|
89
89
|
end
|
90
|
-
search.results.
|
90
|
+
expect(search.results).to eq([@posts[1]])
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'matches multiple keywords with escaped characters' do
|
@@ -95,7 +95,7 @@ describe 'keyword search' do
|
|
95
95
|
keywords 'spirit', :fields => [:title]
|
96
96
|
keywords 'host\'s', :fields => [:body]
|
97
97
|
end
|
98
|
-
search.results.
|
98
|
+
expect(search.results).to eq([@posts[2]])
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'matches multiple keywords with phrase-based search' do
|
@@ -104,7 +104,7 @@ describe 'keyword search' do
|
|
104
104
|
keywords '"interpret the buffer"', :fields => [:body]
|
105
105
|
keywords '"does the"', :fields => [:body]
|
106
106
|
end
|
107
|
-
search.results.
|
107
|
+
expect(search.results).to eq([@posts[2]])
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'matches multiple keywords different options' do
|
@@ -112,7 +112,7 @@ describe 'keyword search' do
|
|
112
112
|
keywords 'insufficient nonexistent', :fields => [:title], :minimum_match => 1
|
113
113
|
keywords 'wind does', :fields => [:body], :minimum_match => 2
|
114
114
|
end
|
115
|
-
search.results.
|
115
|
+
expect(search.results).to eq([@posts[0]])
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -125,9 +125,10 @@ describe 'keyword search' do
|
|
125
125
|
|
126
126
|
it 'should assign a higher score to the result matching the higher-boosted field' do
|
127
127
|
search = Sunspot.search(Post) { keywords 'rhinoceros' }
|
128
|
-
search.hits.map { |hit| hit.primary_key }.
|
128
|
+
expect(search.hits.map { |hit| hit.primary_key }).to eq(
|
129
129
|
@posts.map { |post| post.id.to_s }
|
130
|
-
|
130
|
+
)
|
131
|
+
expect(search.hits.first.score).to be > search.hits.last.score
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
@@ -142,9 +143,10 @@ describe 'keyword search' do
|
|
142
143
|
|
143
144
|
it 'should assign a higher score to the higher-boosted document' do
|
144
145
|
search = Sunspot.search(Post) { keywords 'test' }
|
145
|
-
search.hits.map { |hit| hit.primary_key }.
|
146
|
+
expect(search.hits.map { |hit| hit.primary_key }).to eq(
|
146
147
|
@posts.map { |post| post.id.to_s }
|
147
|
-
|
148
|
+
)
|
149
|
+
expect(search.hits.first.score).to be > search.hits.last.score
|
148
150
|
end
|
149
151
|
end
|
150
152
|
|
@@ -164,8 +166,8 @@ describe 'keyword search' do
|
|
164
166
|
phrase_fields :body => 2.0
|
165
167
|
end
|
166
168
|
end.hits
|
167
|
-
hits.first.instance.
|
168
|
-
hits.first.score.
|
169
|
+
expect(hits.first.instance).to eq(@comments.first)
|
170
|
+
expect(hits.first.score).to be > hits.last.score
|
169
171
|
end
|
170
172
|
|
171
173
|
it 'assigns a higher score to documents in which the search terms appear in a boosted field' do
|
@@ -174,8 +176,8 @@ describe 'keyword search' do
|
|
174
176
|
fields :body => 2.0, :author_name => 0.75
|
175
177
|
end
|
176
178
|
end.hits
|
177
|
-
hits.first.instance.
|
178
|
-
hits.first.score.
|
179
|
+
expect(hits.first.instance).to eq(@comments.first)
|
180
|
+
expect(hits.first.score).to be > hits.last.score
|
179
181
|
end
|
180
182
|
|
181
183
|
it 'assigns a higher score to documents in which the search terms appear in a higher boosted phrase field' do
|
@@ -184,8 +186,8 @@ describe 'keyword search' do
|
|
184
186
|
phrase_fields :body => 2.0, :author_name => 0.75
|
185
187
|
end
|
186
188
|
end.hits
|
187
|
-
hits.first.instance.
|
188
|
-
hits.first.score.
|
189
|
+
expect(hits.first.instance).to eq(@comments.first)
|
190
|
+
expect(hits.first.score).to be > hits.last.score
|
189
191
|
end
|
190
192
|
end
|
191
193
|
|
@@ -210,8 +212,8 @@ describe 'keyword search' do
|
|
210
212
|
end
|
211
213
|
query.without(@posts[1])
|
212
214
|
end
|
213
|
-
search.results.
|
214
|
-
search.hits[0].score.
|
215
|
+
expect(search.results).to eq([@posts[0], @posts[2]])
|
216
|
+
expect(search.hits[0].score).to be > search.hits[1].score
|
215
217
|
end
|
216
218
|
|
217
219
|
it 'should assign scores in order of multiple boost query match' do
|
@@ -221,9 +223,9 @@ describe 'keyword search' do
|
|
221
223
|
boost(1.5) { with(:average_rating).greater_than(3.0) }
|
222
224
|
end
|
223
225
|
end
|
224
|
-
search.results.
|
225
|
-
search.hits[0].score.
|
226
|
-
search.hits[1].score.
|
226
|
+
expect(search.results).to eq(@posts)
|
227
|
+
expect(search.hits[0].score).to be > search.hits[1].score
|
228
|
+
expect(search.hits[1].score).to be > search.hits[2].score
|
227
229
|
end
|
228
230
|
end
|
229
231
|
|
@@ -241,11 +243,11 @@ describe 'keyword search' do
|
|
241
243
|
end
|
242
244
|
|
243
245
|
it 'should match documents that contain the minimum_match number of search terms' do
|
244
|
-
@search.results.
|
246
|
+
expect(@search.results).to include(@posts[0])
|
245
247
|
end
|
246
248
|
|
247
249
|
it 'should not match documents that do not contain the minimum_match number of search terms' do
|
248
|
-
@search.results.
|
250
|
+
expect(@search.results).not_to include(@posts[1])
|
249
251
|
end
|
250
252
|
end
|
251
253
|
|
@@ -264,15 +266,15 @@ describe 'keyword search' do
|
|
264
266
|
end
|
265
267
|
|
266
268
|
it 'should match exact phrase' do
|
267
|
-
@search.results.
|
269
|
+
expect(@search.results).to include(@posts[0])
|
268
270
|
end
|
269
271
|
|
270
272
|
it 'should match phrase divided by query phrase slop terms' do
|
271
|
-
@search.results.
|
273
|
+
expect(@search.results).to include(@posts[1])
|
272
274
|
end
|
273
275
|
|
274
276
|
it 'should not match phrase divided by more than query phrase slop terms' do
|
275
|
-
@search.results.
|
277
|
+
expect(@search.results).not_to include(@posts[2])
|
276
278
|
end
|
277
279
|
end
|
278
280
|
|
@@ -298,15 +300,15 @@ describe 'keyword search' do
|
|
298
300
|
end
|
299
301
|
|
300
302
|
it 'should give phrase field boost to exact match' do
|
301
|
-
@sorted_hits[0].score.
|
303
|
+
expect(@sorted_hits[0].score).to be > @sorted_hits[1].score
|
302
304
|
end
|
303
305
|
|
304
306
|
it 'should give phrase field boost to match within slop' do
|
305
|
-
@sorted_hits[2].score.
|
307
|
+
expect(@sorted_hits[2].score).to be > @sorted_hits[3].score
|
306
308
|
end
|
307
309
|
|
308
310
|
it 'should not give phrase field boost to match beyond slop' do
|
309
|
-
@sorted_hits[4].score.
|
311
|
+
expect(@sorted_hits[4].score).to eq(@sorted_hits[5].score)
|
310
312
|
end
|
311
313
|
end
|
312
314
|
|
@@ -316,8 +318,8 @@ describe 'keyword search' do
|
|
316
318
|
end
|
317
319
|
|
318
320
|
after :each do
|
319
|
-
@search.results.
|
320
|
-
@search.hits.first.score.
|
321
|
+
expect(@search.results).to eq(@posts)
|
322
|
+
expect(@search.hits.first.score).to be > @search.hits.last.score
|
321
323
|
end
|
322
324
|
|
323
325
|
it 'boosts via function query with float' do
|
@@ -25,13 +25,13 @@ describe 'local search' do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should return results in geo order' do
|
28
|
-
@search.results.
|
28
|
+
expect(@search.results).to eq(@posts)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should asssign higher score to closer locations' do
|
32
32
|
hits = @search.hits
|
33
33
|
hits[1..-1].each_with_index do |hit, i|
|
34
|
-
hit.score.
|
34
|
+
expect(hit.score).to be < hits[i].score
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -51,13 +51,13 @@ describe 'local search' do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should take both fulltext and distance into account in ordering' do
|
54
|
-
@search.results.
|
54
|
+
expect(@search.results).to eq(@posts)
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should take both fulltext and distance into account in scoring' do
|
58
58
|
hits = @search.hits
|
59
59
|
hits[1..-1].each_with_index do |hit, i|
|
60
|
-
hit.score.
|
60
|
+
expect(hit.score).to be < hits[i].score
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|