has_searcher 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,10 @@ class Boostificator
6
6
 
7
7
  attr_accessor :m, :x, :a, :b
8
8
 
9
+ attr_accessor :extra_boost
10
+
9
11
  def initialize(options={})
10
- options.reverse_merge!(:a => 1.0, :b => 1.0, :m => 1.0 / MILLIS_IN_YEAR)
12
+ options.reverse_merge!(:a => 1.0, :b => 1.0, :m => 1.0 / MILLIS_IN_YEAR, :extra_boost => 1.0)
11
13
  options.each do |field, value|
12
14
  self.send("#{field}=", value)
13
15
  end
@@ -16,11 +18,16 @@ class Boostificator
16
18
 
17
19
  def adjust_solr_params
18
20
  search.adjust_solr_params do |params|
19
- params[:q] = "{!boost b=map(recip(abs(ms(#{now_s},#{field})),#{m},#{a},#{b}),#{recip_min},#{recip_max},1) defType=dismax}#{params[:q]}" if params[:q]
21
+ params[:boost] = "product(#{extra_boost},#{recip_s})"
22
+ params[:defType] = 'edismax'
20
23
  end
21
24
  end
22
25
 
23
26
  private
27
+ def recip_s
28
+ @recip_s ||= "map(recip(abs(ms(#{now_s},#{field})),#{m},#{a},#{b}),#{recip_min},#{recip_max},1)"
29
+ end
30
+
24
31
  def now
25
32
  @now ||= DateTime.now.change(:min => 0)
26
33
  end
@@ -1,3 +1,3 @@
1
1
  module HasSearcher
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
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.16
4
+ version: 0.0.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-26 00:00:00.000000000 Z
12
+ date: 2012-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &13490880 !ruby/object:Gem::Requirement
16
+ requirement: &14301560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13490880
24
+ version_requirements: *14301560
25
25
  description: ! "This gem adds ability to construct search objects for indexed models.\n
26
26
  \ It works with sunspot, inherited_resources and formtastic"
27
27
  email:
@@ -55,12 +55,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
55
  - - ! '>='
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
+ segments:
59
+ - 0
60
+ hash: -2828897147514902018
58
61
  required_rubygems_version: !ruby/object:Gem::Requirement
59
62
  none: false
60
63
  requirements:
61
64
  - - ! '>='
62
65
  - !ruby/object:Gem::Version
63
66
  version: '0'
67
+ segments:
68
+ - 0
69
+ hash: -2828897147514902018
64
70
  requirements: []
65
71
  rubyforge_project: has_searcher
66
72
  rubygems_version: 1.8.15