zigexn_solr-ruby 0.0.2 → 0.0.3
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.
- data/lib/solr/request.rb +1 -0
- data/lib/solr/request/atomic_update.rb +29 -0
- data/lib/solr/request/commit.rb +0 -2
- metadata +5 -4
data/lib/solr/request.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
class Solr::Request::AtomicUpdate < Solr::Request::Update
|
2
|
+
# Example: Solr::Request::AtomicUpdate.new([:id => 10, :set => {:field_name => "new value"}])
|
3
|
+
def initialize(update_docs)
|
4
|
+
@docs = []
|
5
|
+
update_docs.each do |update_doc|
|
6
|
+
doc = {}
|
7
|
+
[:set, :add, :remove, :removeregex, :inc].each do |mode|
|
8
|
+
field_data = update_doc[mode]
|
9
|
+
if field_data
|
10
|
+
field_data.each do |field_name, field_value|
|
11
|
+
doc[field_name] = {mode => field_value} if field_value
|
12
|
+
end
|
13
|
+
update_doc.delete mode
|
14
|
+
end
|
15
|
+
end
|
16
|
+
doc[update_doc.keys[0].to_s] = update_doc.values[0]
|
17
|
+
@docs << doc
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def content_type
|
22
|
+
'application/json; charset=utf-8'
|
23
|
+
end
|
24
|
+
|
25
|
+
# returns the request as a string suitable for posting
|
26
|
+
def to_s
|
27
|
+
return @docs.to_json
|
28
|
+
end
|
29
|
+
end
|
data/lib/solr/request/commit.rb
CHANGED
@@ -17,13 +17,11 @@ class Solr::Request::Commit < Solr::Request::Update
|
|
17
17
|
def initialize(options={})
|
18
18
|
@wait_searcher = options[:wait_searcher] || true
|
19
19
|
@wait_flush_option = options[:wait_flush_option] || false
|
20
|
-
@wait_flush = options[:wait_flush] || true
|
21
20
|
end
|
22
21
|
|
23
22
|
def to_s
|
24
23
|
e = Solr::XML::Element.new('commit')
|
25
24
|
e.attributes['waitSearcher'] = @wait_searcher ? 'true' : 'false'
|
26
|
-
e.attributes['waitFlush'] = @wait_flush ? 'true' : 'false' if @wait_flush_option
|
27
25
|
e.to_s
|
28
26
|
end
|
29
27
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zigexn_solr-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- ZIGExN
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: exe
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2016-11-
|
18
|
+
date: 2016-11-28 00:00:00 +07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/solr/request/mlt.rb
|
77
77
|
- lib/solr/request/dismax.rb
|
78
78
|
- lib/solr/request/modify_document.rb
|
79
|
+
- lib/solr/request/atomic_update.rb
|
79
80
|
- lib/solr/request/commit.rb
|
80
81
|
- lib/solr/importer.rb
|
81
82
|
- lib/solr/util.rb
|