ruben-sunspot 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/lib/sunspot/query/dismax.rb +1 -1
- data/lib/sunspot/version.rb +1 -1
- data/spec/integration/keyword_search_spec.rb +14 -3
- data/spec/mocks/connection.rb +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/sunspot/query/dismax.rb
CHANGED
@@ -24,7 +24,7 @@ module Sunspot
|
|
24
24
|
if @boost_functions.empty?
|
25
25
|
params = {:q => @keywords}
|
26
26
|
else
|
27
|
-
params = {:q => "{!boost b=#{@boost_functions.map { |boost_function| boost_function.to_s }}
|
27
|
+
params = {:q => "{!boost b=#{@boost_functions.map { |boost_function| boost_function.to_s }} defType=dismax}#{@keywords}"}
|
28
28
|
end
|
29
29
|
params[:fl] = '* score'
|
30
30
|
params[:qf] = @fulltext_fields.values.map { |field| field.to_boosted_field }.join(' ')
|
data/lib/sunspot/version.rb
CHANGED
@@ -305,11 +305,22 @@ describe 'keyword search' do
|
|
305
305
|
end
|
306
306
|
|
307
307
|
it 'boosts via function query with date' do
|
308
|
-
@posts = [Post.new(:title => 'test', :published_at => Time.now),
|
309
|
-
Post.new(:title => 'test', :published_at => Time.now - 60*60*24*31*6)] # roughly six months ago
|
308
|
+
@posts = [Post.new(:title => 'test word', :published_at => Time.now),
|
309
|
+
Post.new(:title => 'test word', :published_at => Time.now - 60*60*24*31*6)] # roughly six months ago
|
310
310
|
Sunspot.index!(@posts)
|
311
311
|
@search = Sunspot.search(Post) do
|
312
|
-
keywords('
|
312
|
+
keywords('test word') do
|
313
|
+
boost function { recip(ms(Time.now, :published_at), 3.16e-11, 1, 1) }
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'boosts via function query with date and phrase query' do
|
319
|
+
@posts = [Post.new(:title => 'test word', :published_at => Time.now),
|
320
|
+
Post.new(:title => 'test word', :published_at => Time.now - 60*60*24*31*6)] # roughly six months ago
|
321
|
+
Sunspot.index!(@posts)
|
322
|
+
@search = Sunspot.search(Post) do
|
323
|
+
keywords('"test word"') do
|
313
324
|
boost function { recip(ms(Time.now, :published_at), 3.16e-11, 1, 1) }
|
314
325
|
end
|
315
326
|
end
|
data/spec/mocks/connection.rb
CHANGED
@@ -106,7 +106,7 @@ module Mock
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def has_last_search_boosted?(boost,value)
|
109
|
-
has_last_search_including?(:q, "{!boost b=#{boost}
|
109
|
+
has_last_search_including?(:q, "{!boost b=#{boost} defType=dismax}#{value}")
|
110
110
|
end
|
111
111
|
|
112
112
|
private
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruben-sunspot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 4
|
10
|
+
version: 1.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mat Brown
|