stretchy 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stretchy/builders/query_builder.rb +1 -1
- data/lib/stretchy/clauses/boost_clause.rb +4 -1
- data/lib/stretchy/clauses/boost_match_clause.rb +7 -5
- data/lib/stretchy/queries/match_query.rb +5 -1
- data/lib/stretchy/utils/validation.rb +1 -1
- data/lib/stretchy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be619dd65900ce5277436c2431d0c9c7740cd494
|
4
|
+
data.tar.gz: c7315e692b34f98ec01e413e347746022eabe835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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
|
-
|
41
|
-
options[:
|
42
|
-
options[:
|
43
|
-
|
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,
|
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 = {}
|
data/lib/stretchy/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|