lsolr 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/lsolr.rb +21 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3e72d7fb3bc264681d82e5656ba32c43698afea9
|
4
|
+
data.tar.gz: cc5c06c93c6833facfad1b7541f8ffca269878e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340eed18a4003881d7e3f340372de73d69b46f6f46fe92fe74dff2651407c1a3314b2bb7df1a37fe1ff9ca2549ee0d3360e797acd1e86df4d81f75d7a568d6c5
|
7
|
+
data.tar.gz: dfed3fb257a0a773ac978814822744bf92cd9334772f24f4e1ad4cb9eb0c2a8cfc896e251630c7b52b5829fe25f0bae0b99b34be0bdb8a7a3d82822c9c64726b
|
data/lib/lsolr.rb
CHANGED
@@ -30,7 +30,7 @@ require 'date'
|
|
30
30
|
# LSolr.build(params).to_s
|
31
31
|
# #=> 'field01:hoge AND field02:fuga AND field03:14 AND field04:7.3 AND field05:true
|
32
32
|
# # AND field06:false AND field07:"7000-07-01T00:00:00Z" AND field08:"6000-05-31T06:31:43Z"
|
33
|
-
# # AND field09:"5000-06-30T12:59:03Z" AND field10:foo~2.0 AND
|
33
|
+
# # AND field09:"5000-06-30T12:59:03Z" AND field10:foo~2.0 AND field11:(1 2 3)
|
34
34
|
# # AND field12:[1 TO 10] AND field13:[20 TO 40} AND field14:[3000-01-01T00:00:00Z TO 4000-12-31T00:00:00Z]
|
35
35
|
# # AND field15:[3.0 TO 4.0]'
|
36
36
|
#
|
@@ -46,6 +46,10 @@ require 'date'
|
|
46
46
|
# left.or(right).to_s
|
47
47
|
# #=> '(bool_field:true AND date_field1:[* TO 2000-06-30T23:59:59Z] AND date_field2:{2000-07-01T00:00:00Z TO 2001-01-01T00:00:00Z})
|
48
48
|
# # OR (bool_field:false AND (date_field1:[* TO 2000-06-30T23:59:59Z] OR date_field2:{2000-07-01T00:00:00Z TO 2001-01-01T00:00:00Z}))'
|
49
|
+
#
|
50
|
+
# @example How to use. Part 4:
|
51
|
+
# LSolr.build('field:value').to_s
|
52
|
+
# #=> 'field:value'
|
49
53
|
class LSolr
|
50
54
|
ArgumentError = Class.new(::ArgumentError)
|
51
55
|
RangeError = Class.new(::RangeError)
|
@@ -66,6 +70,7 @@ class LSolr
|
|
66
70
|
PROXIMITY = '~'
|
67
71
|
BOOST = '^'
|
68
72
|
PHRASE_MATCH_DELIMITER = ' '
|
73
|
+
MULTI_VALUE_MATCH_DELIMITER = ' '
|
69
74
|
FUZZY_MATCH_DISTANCE_RANGE = (0.0..2.0).freeze
|
70
75
|
FORMAT_DATE_TIME = '%Y-%m-%dT%H:%M:%SZ'
|
71
76
|
FORMAT_MILLISECOND_FOR_DATE_TYPE = '%Q'
|
@@ -84,7 +89,7 @@ class LSolr
|
|
84
89
|
class << self
|
85
90
|
# Builds composite query and returns builder instance.
|
86
91
|
#
|
87
|
-
# @param params [Hash{Symbol => String, Integer, Float, true, false, Range, Date, Time}, String] query terms or a raw query
|
92
|
+
# @param params [Hash{Symbol => String, Symbol, Integer, Float, true, false, Range, Date, Time, Array<String, Symbol, Integer>}, String] query terms or a raw query
|
88
93
|
#
|
89
94
|
# @return [LSolr] a instance
|
90
95
|
def build(params)
|
@@ -112,7 +117,7 @@ class LSolr
|
|
112
117
|
def build_array_query(field, values)
|
113
118
|
return new(field) if values.empty?
|
114
119
|
|
115
|
-
|
120
|
+
new(field).match_in(values)
|
116
121
|
end
|
117
122
|
|
118
123
|
def build_range_query(field, value)
|
@@ -244,6 +249,19 @@ class LSolr
|
|
244
249
|
end
|
245
250
|
end
|
246
251
|
|
252
|
+
# Builds a normal multi value query expression.
|
253
|
+
#
|
254
|
+
# @param value [Array<String, Symbol, Integer>] a search words or a filter values
|
255
|
+
#
|
256
|
+
# @return [LSolr] self instance
|
257
|
+
def match_in(values)
|
258
|
+
raise ArgumentError, "#{values.inspect} given. Must be a not empty array." if values.nil? || values.empty? || !values.is_a?(Array)
|
259
|
+
|
260
|
+
values = values.map { |v| clean(v) }
|
261
|
+
@value = "(#{values.join(MULTI_VALUE_MATCH_DELIMITER)})"
|
262
|
+
self
|
263
|
+
end
|
264
|
+
|
247
265
|
# Builds a normal query expression with dates and times.
|
248
266
|
#
|
249
267
|
# @see https://lucene.apache.org/solr/guide/6_6/working-with-dates.html Working with Dates
|
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.1.
|
4
|
+
version: 0.1.8
|
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-16 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.
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.
|
41
|
+
rubygems_version: 2.6.14
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: A query builder of Apache Solr for Ruby
|