stretchy 0.4.5 → 0.4.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7075f76a33416244fc3786635bdda19d1e2e5b6a
4
- data.tar.gz: 3d8eadb1cef913e2e7cc97e97c7df1ef2c917410
3
+ metadata.gz: be619dd65900ce5277436c2431d0c9c7740cd494
4
+ data.tar.gz: c7315e692b34f98ec01e413e347746022eabe835
5
5
  SHA512:
6
- metadata.gz: be3d26637a9a1baf77b661bd5f48082f1b640e66c7e64314787347ce920cb9c98bd00abb2f03271c7c3e8617df70ad5738d4915676de55bfb20bb0129e0c2c73
7
- data.tar.gz: ee74c3c737df88b99f1240fe81fc16319a42fef2d61f7134e24026f2a77da2571f4e7dbd9c80e80ac71a9d92824ecac99c5e974609325a43681bb6e5f1a67272
6
+ metadata.gz: c77565e3ef0f69497770aa5a1b9311e153f4080aa414d6f1e981b0bec26c7237a97e6aebce5d392b6e8f311e857a39f6b28cca7c93759bbd0937641d94751e14
7
+ data.tar.gz: 78b2637b0f5c5aa946c5c4d23475a95036a811897c16968758982d5cf3310fcb486189323c99e66684f6b932cd5af5995c419d24da6ddef04e0fb6da9b1ad6c3
@@ -21,7 +21,7 @@ module Stretchy
21
21
  def add_matches(field, new_matches, options = {})
22
22
  @matches[field] += Array(new_matches)
23
23
  opts = {}
24
- [:operator, :slop, :minimum_should_match, :type].each do |opt|
24
+ [:operator, :slop, :minimum_should_match, :min, :type].each do |opt|
25
25
  opts[opt] = options[opt] if options[opt]
26
26
  end
27
27
  @query_opts[field] = opts
@@ -21,6 +21,7 @@ module Stretchy
21
21
  extend Forwardable
22
22
 
23
23
  delegate [:geo, :range] => :where
24
+ delegate [:fulltext] => :match
24
25
 
25
26
  #
26
27
  # Changes query state to "match" in the context
@@ -32,7 +33,9 @@ module Stretchy
32
33
  #
33
34
  # @return [BoostMatchClause] query with boost match state
34
35
  def match(params = {}, options = {})
35
- BoostMatchClause.new(base).boost_match(params, options)
36
+ clause = BoostMatchClause.new(base)
37
+ clause = clause.boost_match(params, options) unless params.empty? && options.empty?
38
+ clause
36
39
  end
37
40
 
38
41
  #
@@ -37,10 +37,12 @@ module Stretchy
37
37
  end
38
38
 
39
39
  def fulltext(params = {}, options = {})
40
- weight = params.delete(:weight) || options[:weight]
41
- options[:min] = 1
42
- options[:slop] = MatchClause::FULLTEXT_SLOP
43
- clause = MatchClause.new.match(params, options)
40
+ _params = hashify_params(params)
41
+ weight = _params.delete(:weight) || options[:weight]
42
+ options[:min] ||= MatchClause::FULLTEXT_MIN
43
+ options[:slop] ||= MatchClause::FULLTEXT_SLOP
44
+ options[:type] ||= Queries::MatchQuery::MATCH_TYPES.first
45
+ clause = MatchClause.new.match(_params, options)
44
46
  boost = clause.to_boost(weight)
45
47
  base.boost_builder.add_boost(boost) if boost
46
48
  Base.new(base)
@@ -83,7 +85,7 @@ module Stretchy
83
85
  private
84
86
 
85
87
  def match_function(params = {}, options = {})
86
- weight = params.delete(:weight) || options[:weight]
88
+ weight = hashify_params(params).delete(:weight) || options[:weight]
87
89
  clause = MatchClause.new.match(params, options)
88
90
  boost = clause.to_boost(weight)
89
91
  base.boost_builder.add_boost(boost) if boost
@@ -12,7 +12,7 @@ module Stretchy
12
12
  attribute :operator, String
13
13
  attribute :type, String
14
14
  attribute :slop, Integer
15
- attribute :min, String
15
+ attribute :min, Integer
16
16
  attribute :max, Float
17
17
 
18
18
  validations do
@@ -26,6 +26,10 @@ module Stretchy
26
26
  rule :max, type: Numeric
27
27
  end
28
28
 
29
+ def after_initialize(params)
30
+ @min ||= params[:minimum_should_match]
31
+ end
32
+
29
33
  def option_attributes
30
34
  return @opts if @opts
31
35
  @opts = {}
@@ -59,8 +59,8 @@ module Stretchy
59
59
  def initialize(attributes = nil)
60
60
  self.class.attribute_set.set(self, attributes) if attributes
61
61
  set_default_attributes
62
- validate!
63
62
  after_initialize(attributes) if respond_to?(:after_initialize)
63
+ validate!
64
64
  end
65
65
 
66
66
  end
@@ -1,3 +1,3 @@
1
1
  module Stretchy
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stretchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - agius
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-19 00:00:00.000000000 Z
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch