lsolr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lsolr.rb +11 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 611d522d19f5adbfae542ed8d066d5b9f7e0517e
4
- data.tar.gz: 32066b63f4377d5d64e85f4c35965476d1ed6f81
3
+ metadata.gz: 96e3c013273a9d3bdccda3cb4c7980afbce8a365
4
+ data.tar.gz: f979ae4fc720bce5e6ad921f59e86f3eecc9bbf0
5
5
  SHA512:
6
- metadata.gz: fab35b495e36c5d0754fd137f323b854ae08970dda8859d6a21c712175e11c0a95c4750ad7a5f83795e9ed6439c990be2e04c69e4913fd667b88517ce9ce754e
7
- data.tar.gz: 67256e547e5dcdc89d96b89445d5bc119ae1d1b5bd0dfc355d03aeb8a6aec890496fade7e46ccef8987f433b4724b6417411fec6adf04f7a8f227373ed7a1c78
6
+ metadata.gz: 1d8979647d1968947f1d8724f084ba747d23687fbb98e33528156c15ce71be7dd33d1b99d5dfdefcdbd5dcbe7d87bf0e0d11123f81b4d1db8b034f37524add83
7
+ data.tar.gz: 586b22e3e3ec71c3bb751e4fe4cb58dfe91b4e6336cd7b77b66bbfa47965bd720d0bcbf1393754b8023ae7bb4f492bf4767dc92651b0e5e5de35fb19f9b2a747
@@ -26,7 +26,7 @@ class LSolr
26
26
 
27
27
  PROXIMITY = '~'
28
28
  BOOST = '^'
29
- FUZZY_MATCH_DISTANCE_RANGE = (0.0..1.0).freeze
29
+ FUZZY_MATCH_DISTANCE_RANGE = (0.0..2.0).freeze
30
30
 
31
31
  PARENTHESIS_LEFT = '('
32
32
  PARENTHESIS_RIGHT = ')'
@@ -84,6 +84,8 @@ class LSolr
84
84
 
85
85
  # Adds parentheses to query expression.
86
86
  #
87
+ # @see https://lucene.apache.org/solr/guide/7_1/the-standard-query-parser.html#grouping-terms-to-form-sub-queries Grouping Terms to Form Sub-Queries
88
+ #
87
89
  # @return [LSolr] copied self instance
88
90
  def wrap
89
91
  this = dup
@@ -106,11 +108,12 @@ class LSolr
106
108
  #
107
109
  # @see https://lucene.apache.org/solr/guide/7_1/the-standard-query-parser.html#boosting-a-term-with Boosting a Term with "^"
108
110
  #
109
- # @param weight [Float] boost weight
111
+ # @param factor [Float] a boost factor number
110
112
  #
111
113
  # @return [LSolr] self instance
112
- def boost(weight)
113
- @boost = "#{BOOST}#{weight}"
114
+ def boost(factor)
115
+ raise ArgumentError, "The boost factor number must be positive. #{factor} given." if factor <= 0
116
+ @boost = "#{BOOST}#{factor}"
114
117
  self
115
118
  end
116
119
 
@@ -147,7 +150,7 @@ class LSolr
147
150
  #
148
151
  # @return [LSolr] self instance
149
152
  def prefix_match(value)
150
- @value = clean(value, symbols: RESERVED_SYMBOLS - %w[* ?])
153
+ @value = clean(value, symbols: RESERVED_SYMBOLS - %w[* ?]).split.join('?')
151
154
  self
152
155
  end
153
156
 
@@ -161,7 +164,7 @@ class LSolr
161
164
  #
162
165
  # @return [LSolr] self instance
163
166
  def phrase_match(values, distance: 0)
164
- value = values.map { |v| clean(v) }.join(REPLACEMENT_CHAR)
167
+ value = values.map { |v| clean(v).split }.flatten.join(REPLACEMENT_CHAR)
165
168
  proximity_match = distance > 0 ? "#{PROXIMITY}#{distance}" : ''
166
169
  @value = %("#{value}"#{proximity_match})
167
170
  self
@@ -175,9 +178,9 @@ class LSolr
175
178
  # @param distance [Float] a proximity distance
176
179
  #
177
180
  # @return [LSolr] self instance
178
- def fuzzy_match(value, distance: 0.0)
181
+ def fuzzy_match(value, distance: 2.0)
179
182
  raise RangeError, "Out of #{FUZZY_MATCH_DISTANCE_RANGE}. #{distance} given." unless FUZZY_MATCH_DISTANCE_RANGE.member?(distance)
180
- @value = "#{clean(value)}#{PROXIMITY}#{distance}"
183
+ @value = "#{clean(value).split.join}#{PROXIMITY}#{distance}"
181
184
  self
182
185
  end
183
186
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga