lsolr 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lsolr.rb +29 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4274e0bfec1e74ca2120624580aad73461057f1d5912d83ae0dba8ff82b52a5
|
4
|
+
data.tar.gz: a5cb76c8d965d86d6d6b541604fc1a8a23b6a73ba68ae566953677f68b1d95da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcd93b2d0e788cac40d2f942dd67a4245b6bd20d5dcb89d296c5d8fe29379975e8e220399f77201c3e416a9d308044f55a4f9720d5c74022df5b0aeb12adb893
|
7
|
+
data.tar.gz: 83e1c44d830e10fedf551c0fc77baf77adcc191a4da69defbfd8792a8deca754958e3c0751e7afacae73f6d7197bc02ab4942663a5636fd685152db64e8b3aae
|
data/lib/lsolr.rb
CHANGED
@@ -87,10 +87,11 @@ class LSolr
|
|
87
87
|
PHRASE_MATCH_DELIMITER = ' '
|
88
88
|
MULTI_VALUE_MATCH_DELIMITER = ' '
|
89
89
|
FUZZY_MATCH_DISTANCE_RANGE = (0.0..2.0).freeze
|
90
|
-
FORMAT_DATE_TIME = '%Y-%m-%dT%H:%M:%SZ'
|
90
|
+
FORMAT_DATE_TIME = '%Y-%m-%dT%H:%M:%SZ' # rubocop:disable Style/FormatStringToken
|
91
91
|
FORMAT_MILLISECOND_FOR_DATE_TYPE = '%Q'
|
92
92
|
FORMAT_MILLISECOND_FOR_TIME_TYPE = '%L'
|
93
|
-
FORMAT_SECOND = '%s'
|
93
|
+
FORMAT_SECOND = '%s' # rubocop:disable Style/FormatStringToken
|
94
|
+
FORMAT_INSPECT = '#<%<class>s:%<object>#018x `%<query>s`>'
|
94
95
|
|
95
96
|
PARENTHESIS_LEFT = '('
|
96
97
|
PARENTHESIS_RIGHT = ')'
|
@@ -107,6 +108,8 @@ class LSolr
|
|
107
108
|
# @param params [Hash{Symbol => String, Symbol, Integer, Float, true, false, Range, Date, Time, Array<String, Symbol, Integer>}, String] query terms or a raw query
|
108
109
|
#
|
109
110
|
# @return [LSolr] a instance
|
111
|
+
#
|
112
|
+
# @raise [LSolr::ArgumentError] if specified parameters have a not supported type value
|
110
113
|
def build(params)
|
111
114
|
case params
|
112
115
|
when Hash then params.map { |f, v| build_query(f, v) }.reduce { |a, e| a.and(e) }
|
@@ -175,6 +178,8 @@ class LSolr
|
|
175
178
|
# Returns Apache Solr standard lucene type query string.
|
176
179
|
#
|
177
180
|
# @return [String] a stringified query
|
181
|
+
#
|
182
|
+
# @raise [LSolr::IncompleteQueryError] if the query is incompletely
|
178
183
|
def to_s
|
179
184
|
raise IncompleteQueryError, 'Please specify a term of search.' if blank?
|
180
185
|
|
@@ -183,6 +188,15 @@ class LSolr
|
|
183
188
|
|
184
189
|
alias to_str to_s
|
185
190
|
|
191
|
+
# Returns instance information.
|
192
|
+
#
|
193
|
+
# @return [String] instance information
|
194
|
+
def inspect
|
195
|
+
format(FORMAT_INSPECT, class: self.class.name,
|
196
|
+
object: object_id << 1,
|
197
|
+
query: present? ? to_s : '')
|
198
|
+
end
|
199
|
+
|
186
200
|
# A query is blank if term is incomplete in expression.
|
187
201
|
#
|
188
202
|
# @return [true, false]
|
@@ -203,6 +217,8 @@ class LSolr
|
|
203
217
|
# @param name [String, Symbol] a field name
|
204
218
|
#
|
205
219
|
# @return [LSolr] self instance
|
220
|
+
#
|
221
|
+
# @raise [LSolr::ArgumentError] if specified field name is empty
|
206
222
|
def field(name)
|
207
223
|
raise ArgumentError, "The field name must be a not empty string value. #{name.inspect} given." unless present_string?(name)
|
208
224
|
|
@@ -215,6 +231,8 @@ class LSolr
|
|
215
231
|
# @param query [String] a raw query string
|
216
232
|
#
|
217
233
|
# @return [LSolr] self instance
|
234
|
+
#
|
235
|
+
# @raise [LSolr::ArgumentError] if specified raw query string is empty
|
218
236
|
def raw(query)
|
219
237
|
raise ArgumentError, "The raw query must be a not empty string value. #{query.inspect} given." unless present_string?(query)
|
220
238
|
|
@@ -252,6 +270,8 @@ class LSolr
|
|
252
270
|
# @param factor [Float] a boost factor number
|
253
271
|
#
|
254
272
|
# @return [LSolr] self instance
|
273
|
+
#
|
274
|
+
# @raise [LSolr::ArgumentError] if specified boost factor is invalid
|
255
275
|
def boost(factor)
|
256
276
|
raise ArgumentError, "The boost factor must be a positive number. #{factor.inspect} given." unless valid_boost_factor?(factor)
|
257
277
|
|
@@ -266,6 +286,8 @@ class LSolr
|
|
266
286
|
# @param score [Float] a constant score
|
267
287
|
#
|
268
288
|
# @return [LSolr] self instance
|
289
|
+
#
|
290
|
+
# @raise [LSolr::ArgumentError] if specified score number is invalid
|
269
291
|
def constant_score(score)
|
270
292
|
raise ArgumentError, "The constant score must be a number. #{score.inspect} given." unless valid_score?(score)
|
271
293
|
|
@@ -294,6 +316,8 @@ class LSolr
|
|
294
316
|
# @param value [Array<String, Symbol, Integer>] a search words or a filter values
|
295
317
|
#
|
296
318
|
# @return [LSolr] self instance
|
319
|
+
#
|
320
|
+
# @raise [LSolr::ArgumentError] if specified value is a empty array or not array
|
297
321
|
def match_in(values)
|
298
322
|
raise ArgumentError, "#{values.inspect} given. It must be a not empty array." unless present_array?(values)
|
299
323
|
|
@@ -351,6 +375,8 @@ class LSolr
|
|
351
375
|
# @param distance [Float] a proximity distance
|
352
376
|
#
|
353
377
|
# @return [LSolr] self instance
|
378
|
+
#
|
379
|
+
# @raise [LSolr::RangeError] if specified distance is out of range
|
354
380
|
def fuzzy_match(value, distance: 2.0)
|
355
381
|
raise RangeError, "Out of #{FUZZY_MATCH_DISTANCE_RANGE}. #{distance} given." unless FUZZY_MATCH_DISTANCE_RANGE.member?(distance)
|
356
382
|
@value = "#{clean(value).split.join}#{PROXIMITY}#{distance}"
|
@@ -497,7 +523,7 @@ class LSolr
|
|
497
523
|
|
498
524
|
return date.strftime(FORMAT_DATE_TIME) if msec_str == '000'
|
499
525
|
|
500
|
-
"#{date.strftime('%Y-%m-%dT%H:%M:%S')}.#{msec_str}Z"
|
526
|
+
"#{date.strftime('%Y-%m-%dT%H:%M:%S')}.#{msec_str}Z" # rubocop:disable Style/FormatStringToken
|
501
527
|
end
|
502
528
|
|
503
529
|
def link(another, operator)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lsolr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taishi Kasuga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: LSolr is a query builder of Apache Solr standard Lucene type query for
|
14
14
|
Ruby.
|