lsolr 0.0.3 → 0.0.4
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 +4 -4
- data/lib/lsolr.rb +11 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96e3c013273a9d3bdccda3cb4c7980afbce8a365
|
4
|
+
data.tar.gz: f979ae4fc720bce5e6ad921f59e86f3eecc9bbf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d8979647d1968947f1d8724f084ba747d23687fbb98e33528156c15ce71be7dd33d1b99d5dfdefcdbd5dcbe7d87bf0e0d11123f81b4d1db8b034f37524add83
|
7
|
+
data.tar.gz: 586b22e3e3ec71c3bb751e4fe4cb58dfe91b4e6336cd7b77b66bbfa47965bd720d0bcbf1393754b8023ae7bb4f492bf4767dc92651b0e5e5de35fb19f9b2a747
|
data/lib/lsolr.rb
CHANGED
@@ -26,7 +26,7 @@ class LSolr
|
|
26
26
|
|
27
27
|
PROXIMITY = '~'
|
28
28
|
BOOST = '^'
|
29
|
-
FUZZY_MATCH_DISTANCE_RANGE = (0.0..
|
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
|
111
|
+
# @param factor [Float] a boost factor number
|
110
112
|
#
|
111
113
|
# @return [LSolr] self instance
|
112
|
-
def boost(
|
113
|
-
|
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:
|
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
|
|