solr4r 0.2.0 → 0.3.0
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/ChangeLog +12 -0
- data/README +3 -3
- data/Rakefile +1 -1
- data/lib/solr4r/batch.rb +89 -0
- data/lib/solr4r/builder.rb +215 -130
- data/lib/solr4r/client/{admin.rb → admin_mixin.rb} +3 -3
- data/lib/solr4r/client/{query.rb → query_mixin.rb} +4 -3
- data/lib/solr4r/client/{update.rb → update_mixin.rb} +8 -14
- data/lib/solr4r/client.rb +18 -88
- data/lib/solr4r/document.rb +4 -1
- data/lib/solr4r/endpoints.rb +9 -9
- data/lib/solr4r/query.rb +181 -0
- data/lib/solr4r/result.rb +49 -13
- data/lib/solr4r/version.rb +1 -1
- data/lib/solr4r.rb +3 -1
- data/spec/solr4r/builder_spec.rb +33 -2
- data/spec/solr4r/client_spec.rb +14 -0
- metadata +23 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7622780508966d197a2ea3101266d7aa886102c1
|
4
|
+
data.tar.gz: 6082b84092d225e23467b28b90a780c5c8d00b01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27012fe1c76d4dd9d52599c41375ae71bde7929548a84dc781a48d8dd27f508709c0a1a5c55007cd11da7a2fb1ce2a79d2e5223d9d74024444cd37277becf399
|
7
|
+
data.tar.gz: 004c2706c97fd115fe2300ea265c353ac2aca0b878eea57af8ea14a6aae23523bb744bdb8e97d6416fe21568ab7d1238532bc8e50ff7ef509a7f72e7fe7a4045
|
data/ChangeLog
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
= Revision history for solr4r
|
4
4
|
|
5
|
+
== 0.3.0 [2016-03-23]
|
6
|
+
|
7
|
+
* Extended Solr4R::Result for
|
8
|
+
debugging[https://wiki.apache.org/solr/CommonQueryParameters#Debugging].
|
9
|
+
* Extended Solr4R::Result for
|
10
|
+
highlighting[https://wiki.apache.org/solr/HighlightingParameters].
|
11
|
+
* Extended Solr4R::Result for
|
12
|
+
spellchecking[https://wiki.apache.org/solr/SpellCheckComponent].
|
13
|
+
* Added support for date-/time objects and ranges.
|
14
|
+
* Refactored Solr4R::Client, Solr4R::Builder, Solr4R::Document,
|
15
|
+
Solr4R::Result.
|
16
|
+
|
5
17
|
== 0.2.0 [2015-12-14]
|
6
18
|
|
7
19
|
* Updated Solr4R::Client::Query#more_like_this_q for Solr 5.4.0.
|
data/README
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
== VERSION
|
4
4
|
|
5
|
-
This documentation refers to solr4r version 0.
|
5
|
+
This documentation refers to solr4r version 0.3.0
|
6
6
|
|
7
7
|
|
8
8
|
== DESCRIPTION
|
9
9
|
|
10
|
-
|
10
|
+
Access the {Apache Solr}[http://lucene.apache.org/solr/] search server from Ruby.
|
11
11
|
|
12
12
|
|
13
13
|
== LINKS
|
@@ -25,7 +25,7 @@ Travis CI:: https://travis-ci.org/blackwinter/solr4r
|
|
25
25
|
|
26
26
|
== LICENSE AND COPYRIGHT
|
27
27
|
|
28
|
-
Copyright (C) 2014-
|
28
|
+
Copyright (C) 2014-2016 Jens Wille
|
29
29
|
|
30
30
|
solr4r is free software: you can redistribute it and/or modify it
|
31
31
|
under the terms of the GNU Affero General Public License as published by
|
data/Rakefile
CHANGED
data/lib/solr4r/batch.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
#--
|
4
|
+
###############################################################################
|
5
|
+
# #
|
6
|
+
# solr4r -- A Ruby client for Apache Solr #
|
7
|
+
# #
|
8
|
+
# Copyright (C) 2014-2016 Jens Wille #
|
9
|
+
# #
|
10
|
+
# solr4r is free software: you can redistribute it and/or modify it under the #
|
11
|
+
# terms of the GNU Affero General Public License as published by the Free #
|
12
|
+
# Software Foundation, either version 3 of the License, or (at your option) #
|
13
|
+
# any later version. #
|
14
|
+
# #
|
15
|
+
# solr4r is distributed in the hope that it will be useful, but WITHOUT ANY #
|
16
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
17
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for #
|
18
|
+
# more details. #
|
19
|
+
# #
|
20
|
+
# You should have received a copy of the GNU Affero General Public License #
|
21
|
+
# along with solr4r. If not, see <http://www.gnu.org/licenses/>. #
|
22
|
+
# #
|
23
|
+
###############################################################################
|
24
|
+
#++
|
25
|
+
|
26
|
+
module Solr4R
|
27
|
+
|
28
|
+
class Batch
|
29
|
+
|
30
|
+
STEP = 10
|
31
|
+
|
32
|
+
DEFAULT_SIZE = STEP ** 3
|
33
|
+
|
34
|
+
def initialize(client, attributes = {},
|
35
|
+
params = {}, options = {}, size = DEFAULT_SIZE, &block)
|
36
|
+
@client, @args, @size, @block =
|
37
|
+
client, [attributes, params, options], size, block
|
38
|
+
|
39
|
+
reset
|
40
|
+
end
|
41
|
+
|
42
|
+
attr_reader :client
|
43
|
+
|
44
|
+
attr_accessor :size
|
45
|
+
|
46
|
+
def reset
|
47
|
+
@batch, @failed = [], []
|
48
|
+
end
|
49
|
+
|
50
|
+
def clear
|
51
|
+
@batch.clear
|
52
|
+
end
|
53
|
+
|
54
|
+
def add(*docs)
|
55
|
+
batch(docs)
|
56
|
+
end
|
57
|
+
|
58
|
+
alias_method :<<, :add
|
59
|
+
|
60
|
+
def batch(docs)
|
61
|
+
flush unless @batch.concat(docs).size < size
|
62
|
+
end
|
63
|
+
|
64
|
+
def flush
|
65
|
+
process
|
66
|
+
clear
|
67
|
+
@failed
|
68
|
+
end
|
69
|
+
|
70
|
+
def inspect
|
71
|
+
'#<%s:0x%x @size=%p, @count=%p, @failed=%p>' % [
|
72
|
+
self.class, object_id, size, @batch.size, @failed.size
|
73
|
+
]
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def process(docs = @batch, size = size())
|
79
|
+
next_size = size.fdiv(STEP).ceil
|
80
|
+
|
81
|
+
docs.each_slice(size) { |batch|
|
82
|
+
client.add(batch, *@args, &@block).success? ? nil :
|
83
|
+
size > 1 ? process(batch, next_size) : @failed.concat(batch)
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
data/lib/solr4r/builder.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# #
|
6
6
|
# solr4r -- A Ruby client for Apache Solr #
|
7
7
|
# #
|
8
|
-
# Copyright (C) 2014-
|
8
|
+
# Copyright (C) 2014-2016 Jens Wille #
|
9
9
|
# #
|
10
10
|
# solr4r is free software: you can redistribute it and/or modify it under the #
|
11
11
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -24,6 +24,7 @@
|
|
24
24
|
#++
|
25
25
|
|
26
26
|
require 'nokogiri'
|
27
|
+
require 'time'
|
27
28
|
|
28
29
|
module Solr4R
|
29
30
|
|
@@ -43,95 +44,129 @@ module Solr4R
|
|
43
44
|
|
44
45
|
ILLEGAL_CHAR_RE = /[\x00-\x08\x0B\x0C\x0E-\x1F]/
|
45
46
|
|
46
|
-
|
47
|
+
class << self
|
48
|
+
|
49
|
+
def convert_value(value)
|
50
|
+
case value
|
51
|
+
when Time then value.getutc.xmlschema
|
52
|
+
when DateTime then convert_value(value.to_time)
|
53
|
+
when Date then convert_value(value.to_datetime)
|
54
|
+
else value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize(client = Client, options = nil)
|
47
61
|
raise ArgumentError,
|
48
62
|
'block argument not supported, use options hash instead' if block_given?
|
49
63
|
|
50
64
|
@client = client
|
51
65
|
|
52
|
-
@
|
53
|
-
@
|
66
|
+
@solr4r_doc = doc = Document.new
|
67
|
+
@solr4r_opt = opt = DEFAULT_OPTIONS.dup
|
68
|
+
|
69
|
+
options ||= client.respond_to?(:options) ? client.options : {}
|
70
|
+
options.each { |k, v| opt[k.to_sym] = v if doc.respond_to?("#{k}=") }
|
54
71
|
|
55
|
-
super(@solr4r_opt
|
72
|
+
super(@solr4r_opt, @solr4r_doc)
|
56
73
|
end
|
57
74
|
|
58
75
|
attr_reader :client
|
59
76
|
|
60
|
-
# See Schema[
|
77
|
+
# See Schema[https://wiki.apache.org/solr/UpdateXmlMessages#add.2Freplace_documents].
|
61
78
|
#
|
62
|
-
# Examples:
|
79
|
+
# ==== Examples:
|
80
|
+
#
|
81
|
+
# ===== Single document
|
63
82
|
#
|
64
|
-
# # single document
|
65
83
|
# add(employeeId: '05991', office: 'Bridgewater', skills: %w[Perl Java])
|
66
84
|
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
# </
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
85
|
+
# Result:
|
86
|
+
#
|
87
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
88
|
+
# <add>
|
89
|
+
# <doc>
|
90
|
+
# <field name="employeeId">05991</field>
|
91
|
+
# <field name="office">Bridgewater</field>
|
92
|
+
# <field name="skills">Perl</field>
|
93
|
+
# <field name="skills">Java</field>
|
94
|
+
# </doc>
|
95
|
+
# </add>
|
96
|
+
#
|
97
|
+
# ===== Multiple documents
|
98
|
+
#
|
78
99
|
# add([{ employeeId: '05992', office: 'Blackwater' }, { employeeId: '05993', skills: 'Ruby' }])
|
79
100
|
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
# </
|
86
|
-
# <
|
87
|
-
#
|
88
|
-
#
|
89
|
-
# </
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
101
|
+
# Result:
|
102
|
+
#
|
103
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
104
|
+
# <add>
|
105
|
+
# <doc>
|
106
|
+
# <field name="employeeId">05992</field>
|
107
|
+
# <field name="office">Blackwater</field>
|
108
|
+
# </doc>
|
109
|
+
# <doc>
|
110
|
+
# <field name="employeeId">05993</field>
|
111
|
+
# <field name="skills">Ruby</field>
|
112
|
+
# </doc>
|
113
|
+
# </add>
|
114
|
+
#
|
115
|
+
# ===== Add attributes
|
116
|
+
#
|
93
117
|
# add([id: 42, text: 'blah'], commitWithin: 23)
|
94
118
|
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
# </
|
101
|
-
#
|
119
|
+
# Result:
|
120
|
+
#
|
121
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
122
|
+
# <add commitWithin="23">
|
123
|
+
# <doc>
|
124
|
+
# <field name="id">42</field>
|
125
|
+
# <field name="text">blah</field>
|
126
|
+
# </doc>
|
127
|
+
# </add>
|
128
|
+
#
|
129
|
+
# ===== Document attributes
|
102
130
|
#
|
103
|
-
# # document attributes
|
104
131
|
# add([[{ id: 42, text: 'blah' }, boost: 10.0]])
|
105
132
|
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
# </
|
112
|
-
#
|
133
|
+
# Result:
|
134
|
+
#
|
135
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
136
|
+
# <add>
|
137
|
+
# <doc boost="10.0">
|
138
|
+
# <field name="id">42</field>
|
139
|
+
# <field name="text">blah</field>
|
140
|
+
# </doc>
|
141
|
+
# </add>
|
142
|
+
#
|
143
|
+
# ===== Field attributes
|
113
144
|
#
|
114
|
-
# # field attributes
|
115
145
|
# add(id: 42, text: ['blah', boost: 2.0])
|
116
146
|
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
# </
|
123
|
-
#
|
147
|
+
# Result:
|
148
|
+
#
|
149
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
150
|
+
# <add>
|
151
|
+
# <doc>
|
152
|
+
# <field name="id">42</field>
|
153
|
+
# <field name="text" boost="2.0">blah</field>
|
154
|
+
# </doc>
|
155
|
+
# </add>
|
156
|
+
#
|
157
|
+
# ===== All attributes together
|
124
158
|
#
|
125
|
-
# # all attributes together
|
126
159
|
# add([[{ id: 42, text: ['blah', boost: 2.0] }, boost: 10.0]], commitWithin: 23)
|
127
160
|
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
# </
|
134
|
-
#
|
161
|
+
# Result:
|
162
|
+
#
|
163
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
164
|
+
# <add commitWithin="23">
|
165
|
+
# <doc boost="10.0">
|
166
|
+
# <field name="id">42</field>
|
167
|
+
# <field name="text" boost="2.0">blah</field>
|
168
|
+
# </doc>
|
169
|
+
# </add>
|
135
170
|
def add(doc, attributes = {})
|
136
171
|
to_xml(:add, attributes) { |add_node| _each(doc) { |hash, doc_attributes|
|
137
172
|
add_node.doc_(doc_attributes) { |doc_node| hash.each { |key, values|
|
@@ -141,137 +176,179 @@ module Solr4R
|
|
141
176
|
field_attributes.update((values = values.dup).pop)
|
142
177
|
end
|
143
178
|
|
144
|
-
|
179
|
+
_each_value(values) { |value| doc_node.field_(value, field_attributes) }
|
145
180
|
} }
|
146
181
|
} }
|
147
182
|
end
|
148
183
|
|
149
184
|
alias_method :doc, :add
|
150
185
|
|
151
|
-
# See Schema[
|
186
|
+
# See Schema[https://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22].
|
187
|
+
#
|
188
|
+
# ==== Examples:
|
152
189
|
#
|
153
|
-
#
|
190
|
+
# ===== Without options
|
154
191
|
#
|
155
192
|
# commit
|
156
193
|
#
|
157
|
-
#
|
158
|
-
#
|
194
|
+
# Result:
|
195
|
+
#
|
196
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
197
|
+
# <commit/>
|
198
|
+
#
|
199
|
+
# ===== With options
|
159
200
|
#
|
160
201
|
# commit(softCommit: true)
|
161
202
|
#
|
162
|
-
#
|
163
|
-
#
|
203
|
+
# Result:
|
204
|
+
#
|
205
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
206
|
+
# <commit softCommit="true"/>
|
164
207
|
def commit(attributes = {})
|
165
208
|
to_xml(:commit, attributes)
|
166
209
|
end
|
167
210
|
|
168
|
-
# See Schema[
|
211
|
+
# See Schema[https://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22].
|
169
212
|
#
|
170
|
-
# Examples:
|
213
|
+
# ==== Examples:
|
214
|
+
#
|
215
|
+
# ===== Without options
|
171
216
|
#
|
172
217
|
# optimize
|
173
218
|
#
|
174
|
-
#
|
175
|
-
#
|
219
|
+
# Result:
|
220
|
+
#
|
221
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
222
|
+
# <optimize/>
|
223
|
+
#
|
224
|
+
# ===== With options
|
176
225
|
#
|
177
226
|
# optimize(maxSegments: 42)
|
178
227
|
#
|
179
|
-
#
|
180
|
-
#
|
228
|
+
# Result:
|
229
|
+
#
|
230
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
231
|
+
# <optimize maxSegments="42"/>
|
181
232
|
def optimize(attributes = {})
|
182
233
|
to_xml(:optimize, attributes)
|
183
234
|
end
|
184
235
|
|
185
|
-
# See Schema[
|
236
|
+
# See Schema[https://wiki.apache.org/solr/UpdateXmlMessages#A.22rollback.22].
|
186
237
|
#
|
187
|
-
# Example:
|
238
|
+
# ==== Example:
|
188
239
|
#
|
189
240
|
# rollback
|
190
241
|
#
|
191
|
-
#
|
192
|
-
#
|
242
|
+
# Result:
|
243
|
+
#
|
244
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
245
|
+
# <rollback/>
|
193
246
|
def rollback
|
194
247
|
to_xml(:rollback)
|
195
248
|
end
|
196
249
|
|
197
|
-
# See Schema[
|
250
|
+
# See Schema[https://wiki.apache.org/solr/UpdateXmlMessages#A.22delete.22_documents_by_ID_and_by_Query].
|
251
|
+
#
|
252
|
+
# See Query#query_string for handling of query hashes (via +client.query_string+).
|
198
253
|
#
|
199
|
-
#
|
254
|
+
# ==== Examples:
|
200
255
|
#
|
201
|
-
#
|
256
|
+
# ===== Single ID
|
202
257
|
#
|
203
|
-
# # single ID
|
204
258
|
# delete(id: '05991')
|
205
259
|
#
|
206
|
-
#
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
260
|
+
# Result:
|
261
|
+
#
|
262
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
263
|
+
# <delete>
|
264
|
+
# <id>05991</id>
|
265
|
+
# </delete>
|
266
|
+
#
|
267
|
+
# ===== Multiple IDs
|
210
268
|
#
|
211
|
-
# # multiple IDs
|
212
269
|
# delete(id: %w[05991 06000])
|
213
270
|
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
# </
|
271
|
+
# Result:
|
272
|
+
#
|
273
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
274
|
+
# <delete>
|
275
|
+
# <id>05991</id>
|
276
|
+
# <id>06000</id>
|
277
|
+
# </delete>
|
278
|
+
#
|
279
|
+
# ===== Single query
|
219
280
|
#
|
220
|
-
# # single query
|
221
281
|
# delete(query: 'office:Bridgewater')
|
222
282
|
#
|
223
|
-
#
|
224
|
-
#
|
225
|
-
#
|
226
|
-
#
|
283
|
+
# Result:
|
284
|
+
#
|
285
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
286
|
+
# <delete>
|
287
|
+
# <query>office:Bridgewater</query>
|
288
|
+
# </delete>
|
289
|
+
#
|
290
|
+
# ===== Multiple queries
|
227
291
|
#
|
228
|
-
# # multiple queries
|
229
292
|
# delete(query: %w[office:Bridgewater office:Osaka])
|
230
293
|
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
235
|
-
# </
|
294
|
+
# Result:
|
295
|
+
#
|
296
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
297
|
+
# <delete>
|
298
|
+
# <query>office:Bridgewater</query>
|
299
|
+
# <query>office:Osaka</query>
|
300
|
+
# </delete>
|
301
|
+
#
|
302
|
+
# ===== Query hash
|
236
303
|
#
|
237
|
-
# # query hash
|
238
304
|
# delete(query: { office: 'Bridgewater', skills: 'Perl' })
|
239
305
|
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
#
|
243
|
-
#
|
306
|
+
# Result:
|
307
|
+
#
|
308
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
309
|
+
# <delete>
|
310
|
+
# <query>office:Bridgewater skills:Perl</query>
|
311
|
+
# </delete>
|
312
|
+
#
|
313
|
+
# ===== Query hash with array
|
244
314
|
#
|
245
|
-
# # query hash with array
|
246
315
|
# delete(query: { office: %w[Bridgewater Osaka] })
|
247
316
|
#
|
248
|
-
#
|
249
|
-
#
|
250
|
-
#
|
251
|
-
#
|
317
|
+
# Result:
|
318
|
+
#
|
319
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
320
|
+
# <delete>
|
321
|
+
# <query>office:Bridgewater office:Osaka</query>
|
322
|
+
# </delete>
|
323
|
+
#
|
324
|
+
# ===== Query hash with LocalParams[https://wiki.apache.org/solr/LocalParams]
|
252
325
|
#
|
253
|
-
# # query hash with LocalParams
|
254
326
|
# delete(query: { office: 'Bridgewater', _: { type: :edismax } })
|
255
327
|
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
328
|
+
# Result:
|
329
|
+
#
|
330
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
331
|
+
# <delete>
|
332
|
+
# <query>{!type=edismax}office:Bridgewater</query>
|
333
|
+
# </delete>
|
334
|
+
#
|
335
|
+
# ===== Both IDs and queries
|
260
336
|
#
|
261
|
-
# # both IDs and queries
|
262
337
|
# delete(id: %w[05991 06000], query: { office: %w[Bridgewater Osaka] })
|
263
338
|
#
|
264
|
-
#
|
265
|
-
#
|
266
|
-
#
|
267
|
-
#
|
268
|
-
#
|
269
|
-
# </
|
339
|
+
# Result:
|
340
|
+
#
|
341
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
342
|
+
# <delete>
|
343
|
+
# <id>05991</id>
|
344
|
+
# <id>06000</id>
|
345
|
+
# <query>office:Bridgewater office:Osaka</query>
|
346
|
+
# </delete>
|
270
347
|
def delete(hash)
|
271
348
|
to_xml(:delete) { |delete_node| hash.each { |key, values|
|
272
349
|
case key.to_s
|
273
|
-
when 'id' then
|
274
|
-
when 'query' then
|
350
|
+
when 'id' then _each_value(values) { |value| delete_node.id_(value) }
|
351
|
+
when 'query' then _each_value(values) { |value| delete_node.query_(
|
275
352
|
client.query_string(value, false)) }
|
276
353
|
else raise ArgumentError, "`id' or `query' expected, got %p" % key
|
277
354
|
end
|
@@ -295,7 +372,15 @@ module Solr4R
|
|
295
372
|
end
|
296
373
|
|
297
374
|
def _each(values, &block)
|
298
|
-
(values.
|
375
|
+
(values.respond_to?(:to_ary) ? values : [values]).each(&block)
|
376
|
+
end
|
377
|
+
|
378
|
+
def _each_value(values)
|
379
|
+
_each(values) { |value| yield convert_value(value) }
|
380
|
+
end
|
381
|
+
|
382
|
+
def convert_value(value)
|
383
|
+
self.class.convert_value(value)
|
299
384
|
end
|
300
385
|
|
301
386
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# #
|
6
6
|
# solr4r -- A Ruby client for Apache Solr #
|
7
7
|
# #
|
8
|
-
# Copyright (C) 2014-
|
8
|
+
# Copyright (C) 2014-2016 Jens Wille #
|
9
9
|
# #
|
10
10
|
# solr4r is free software: you can redistribute it and/or modify it under the #
|
11
11
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -34,7 +34,7 @@ module Solr4R
|
|
34
34
|
DEFAULT_ANALYZE_DOCUMENT_PATH = 'analysis/document'
|
35
35
|
DEFAULT_ANALYZE_FIELD_PATH = 'analysis/field'
|
36
36
|
|
37
|
-
module
|
37
|
+
module AdminMixin
|
38
38
|
|
39
39
|
def solr_version(type = :spec,
|
40
40
|
params = {}, options = {}, path = DEFAULT_SYSTEM_PATH, &block)
|
@@ -77,7 +77,7 @@ module Solr4R
|
|
77
77
|
|
78
78
|
end
|
79
79
|
|
80
|
-
include
|
80
|
+
include AdminMixin
|
81
81
|
|
82
82
|
end
|
83
83
|
|