logstash-output-custom-solr 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e8d36ffe58c415d72da31b08f3b2e3678d9deb61ae2b7deb5ed500674150062
4
- data.tar.gz: 5f9363c482e2d8054af5ea5dcb3a1c5ff74e400c9859254ea2d8a93dcc1a78d5
3
+ metadata.gz: 352ec3438631b436ea2432b8146a601e9b5c5f78fe11d36708de700964511ec9
4
+ data.tar.gz: fdc03fdf4931310b1aea3e563c2779276bd4a8f2716cee108d80f43b93224351
5
5
  SHA512:
6
- metadata.gz: f5740cfaab73d7102b06f95be3448419583366fefa8e19ec4dd22f9604fe351e8be31dcaea7eef07244a826429788fe3c1de333272adcd3e3daa19ce99479a33
7
- data.tar.gz: d121012fdfa6e63995e32ede417210c9bc7874a5fe73c0f8d6c8e34006a79197608167158fc3305889e5d404a1c5cf29b787cfe48ca19851714d5a73d8ab2e08
6
+ metadata.gz: 6af46d59b27cfaae98dfb781885fd7136df8da44b009030dc8036c90e66cb9dfc31a1c4d06e5e9d099c946ff57a87a5f0c74cdba74ff59797407ffc81c706027
7
+ data.tar.gz: 042db23fbf4d788c21b57e4fbdff63a38d8847835ced2daa62791edf5eb3a13f4f4c9cfe3323cb4b4cb04353c39e1effed629d99b0fde2145445ec5e293b529d
@@ -22,6 +22,9 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
22
22
  # The SolrCloud collection name.
23
23
  config :collection, :validate => :string, :default => 'collection1'
24
24
 
25
+ # A field name with the name of collection to send document to
26
+ config :collection_field, :validate => :string, :default => nil
27
+
25
28
  # Commit every batch?
26
29
  config :commit, :validate => :boolean, :default => false
27
30
 
@@ -77,7 +80,7 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
77
80
 
78
81
  public
79
82
  def flush(events, close=false)
80
- documents = []
83
+ documents_per_col = {}
81
84
 
82
85
  events.each do |event|
83
86
  document = event.to_hash()
@@ -92,7 +95,15 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
92
95
 
93
96
  @logger.info 'Record: %s' % document.inspect
94
97
 
98
+ if !@collection_field and document.has_key?(@collection_field) then
99
+ collection = document[@collection_field]
100
+ else
101
+ collection = @collection
102
+ end
103
+
104
+ documents = documents_per_col.fetch(collection, [])
95
105
  documents.push(document)
106
+ documents_per_col[collection] = documents
96
107
  end
97
108
 
98
109
  params = {}
@@ -100,12 +111,15 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
100
111
  params[:commit] = true
101
112
  end
102
113
  params[:commitWithin] = @commitWithin
103
- if @mode == MODE_STANDALONE then
104
- @solr.add documents, :params => params
105
- @logger.info 'Added %d document(s) to Solr' % documents.count
106
- elsif @mode == MODE_SOLRCLOUD then
107
- @solr.add documents, collection: @collection, :params => params
108
- @logger.info 'Added %d document(s) to Solr' % documents.count
114
+
115
+ hash.each do |collection, documents|
116
+ if @mode == MODE_STANDALONE then
117
+ @solr.add documents, :params => params
118
+ @logger.info 'Added %d document(s) to Solr' % documents.count
119
+ elsif @mode == MODE_SOLRCLOUD then
120
+ @solr.add documents, collection: @collection, :params => params
121
+ @logger.info 'Added %d document(s) to "%s" collection' % documents.count, collection
122
+ end
109
123
  end
110
124
 
111
125
  rescue Exception => e
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-custom-solr'
3
- s.version = "0.1.7"
3
+ s.version = "0.1.8"
4
4
  s.licenses = ["Apache License (2.0)"]
5
5
  s.summary = "Logstash output plugin for sending data to Solr."
6
6
  s.description = "Logstash output plugin for sending data to Solr. It supports SolrCloud, not only Standalone Solr."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-custom-solr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minoru Osuka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-20 00:00:00.000000000 Z
11
+ date: 2018-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement