has_searcher 0.0.95.3 → 0.0.95.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,50 +6,56 @@ class Searcher::Boostificator
6
6
 
7
7
  attr_accessor :m, :x, :a, :b
8
8
 
9
- attr_accessor :extra_boost
9
+ attr_accessor :now
10
+
11
+ attr_accessor :boosts
10
12
 
11
13
  def initialize(boost_field, options={})
12
14
  self.boost_field = boost_field
13
- options.reverse_merge!(:a => 1.0, :b => 1.0, :m => 1.0 / MILLIS_IN_YEAR, :extra_boost => 1.0)
15
+ options.reverse_merge!(:a => 1.0, :b => 1.0, :m => 1.0 / MILLIS_IN_YEAR)
14
16
  options.each do |attribute, value|
15
17
  self.send("#{attribute}=", value)
16
18
  end
17
19
  end
18
20
 
19
-
20
- def adjust_solr_params(sunspot)
21
- sunspot.adjust_solr_params do |params|
22
- params[:boost] = "product(#{extra_boost},#{recip_s})"
23
- params[:defType] = 'edismax'
21
+ def adjust_solr_params(searcher)
22
+ searcher.configuration.scope do |sunspot|
23
+ sunspot.adjust_solr_params do |params|
24
+ params[:boost] = boosts + [recip_s]
25
+ params[:defType] = 'edismax'
26
+ end
24
27
  end
25
28
  end
26
29
 
27
- private
28
- def recip_s
29
- @recip_s ||= "map(recip(abs(ms(#{now_s},#{boost_field})),#{m},#{a},#{b}),#{recip_min},#{recip_max},1)"
30
- end
30
+ def boosts
31
+ @boosts ||= []
32
+ end
31
33
 
32
- def now
33
- @now ||= HasSearcher.cacheable_now
34
- end
34
+ def recip_s
35
+ @recip_s ||= "map(recip(abs(ms(#{now_s},#{boost_field})),#{m},#{a},#{b}),#{recip_min},#{recip_max},1)"
36
+ end
35
37
 
36
- def recip
37
- @recip ||= a / (m * now_ms + b)
38
- end
38
+ def now
39
+ @now ||= HasSearcher.cacheable_now
40
+ end
39
41
 
40
- def now_ms
41
- @now_ms ||= now.to_i * 1000
42
- end
42
+ def recip
43
+ @recip ||= a / (m * now_ms + b)
44
+ end
43
45
 
44
- def now_s
45
- @now_s ||= now.utc.to_datetime.to_time.iso8601
46
- end
46
+ def now_ms
47
+ @now_ms ||= now.to_i * 1000
48
+ end
47
49
 
48
- def recip_min
49
- @recip_min ||= sprintf("%f", (recip * 10**PRECISION).floor/10.0**PRECISION)
50
- end
50
+ def now_s
51
+ @now_s ||= now.utc.to_datetime.to_time.iso8601
52
+ end
51
53
 
52
- def recip_max
53
- @recip_max ||= sprintf("%f", (recip * 10**PRECISION).ceil/10.0**PRECISION)
54
- end
54
+ def recip_min
55
+ @recip_min ||= sprintf("%f", (recip * 10**PRECISION).floor/10.0**PRECISION)
56
+ end
57
+
58
+ def recip_max
59
+ @recip_max ||= sprintf("%f", (recip * 10**PRECISION).ceil/10.0**PRECISION)
60
+ end
55
61
  end
@@ -1,3 +1,3 @@
1
1
  module HasSearcher
2
- VERSION = "0.0.95.3"
2
+ VERSION = "0.0.95.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_searcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.95.3
4
+ version: 0.0.95.4
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-10-09 00:00:00.000000000 Z
12
+ date: 2012-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  segments:
148
148
  - 0
149
- hash: -4088489999752866781
149
+ hash: 979056079572079856
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  none: false
152
152
  requirements:
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  segments:
157
157
  - 0
158
- hash: -4088489999752866781
158
+ hash: 979056079572079856
159
159
  requirements: []
160
160
  rubyforge_project:
161
161
  rubygems_version: 1.8.24