logstash-output-custom-solr 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3205d97edee2f83daa2f520b29c26415162ab97a66f241c014a0d64004ba744
4
- data.tar.gz: cf361397e3a85d1be0d8a97ab96576a7fbfe4a5e40585e3142f29635112a04bd
3
+ metadata.gz: 86a1d9be1b49383ea421b542e8f6b0e3c6c304b6508ec6e816d0b2909c8112a8
4
+ data.tar.gz: fbad8b4206fdb73820455507da630268669613dce94d8179a842a979188beb7c
5
5
  SHA512:
6
- metadata.gz: c9da08f12bcb572406aa6777cccfa8b03b1d40338cac3a354326b2ebedae8c7daec70488d083cff9d60200b12afdf98b917d79f5e8e5f5638a51663da9e2271c
7
- data.tar.gz: c54d0d8e30e69e8a6c73ec7c579255a00a7d6c85b05196f6173905e4d43e2301019200e8fd98aea1e4ac0e40a834772c05d5ec4e3f28bdc15d12b9f4abde9537
6
+ metadata.gz: '099c1b1bb09b013a0933bccf58e0f6535114b7ce062ef7ab6dfc130bea3fb2de6bbffb381f2b8e3594fa007994397291f416b8645645ec1184d2a188fad40e55'
7
+ data.tar.gz: 227b28125f95de3a9c11b0767f40f80bca346f2c7085ecdc638a81b0feaea8eec19d1dc4f3184cd2cf6a22115f37a5e1ef029bee0168b00e3bd1e4e34f2de11e
@@ -22,15 +22,11 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
22
22
  # The SolrCloud collection name.
23
23
  config :collection, :validate => :string, :default => 'collection1'
24
24
 
25
- # The defined fields in the Solr schema.xml. If omitted, it will get fields via Solr Schema API.
26
- config :defined_fields, :validate => :array, :default => nil
27
- # Ignore undefined fields in the Solr schema.xml.
28
- config :ignore_undefined_fields, :validate => :boolean, :default => false
25
+ # Commit every batch?
26
+ config :commit, :validate => :boolean, :default => false
29
27
 
30
- # A field name of unique key in the Solr schema.xml. If omitted, it will get unique key via Solr Schema API.
31
- config :unique_key_field, :validate => :string, :default => nil
32
- # A field name of event timestamp in the Solr schema.xml (default event_timestamp).
33
- config :timestamp_field, :validate => :string, :default => 'event_timestamp'
28
+ # Solr commitWithin parameter
29
+ config :commitWithin, :validate => :number, :default => 10000
34
30
 
35
31
  # The batch size used in update.
36
32
  config :flush_size, :validate => :number, :default => 100
@@ -77,39 +73,24 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
77
73
  def flush(events, close=false)
78
74
  documents = []
79
75
 
80
- #@fields = @defined_fields.nil? || @defined_fields.empty? ? get_fields : @defined_fields
81
-
82
- #@unique_key = @unique_key_field.nil? ? get_unique_key : @unique_key_field
83
-
84
76
  events.each do |event|
85
77
  document = event.to_hash()
86
78
 
87
- #unless document.has_key?(@unique_key) then
88
- #document.merge!({@unique_key => SecureRandom.uuid})
89
- #end
90
-
91
- #unless document.has_key?(@timestamp_field) then
92
- #document.merge!({@timestamp_field => document['@timestamp']})
93
- #end
94
-
95
- #if @ignore_undefined_fields then
96
- #document.each_key do |key|
97
- #unless @fields.include?(key) then
98
- #document.delete(key)
99
- #end
100
- #end
101
- #end
102
-
103
79
  @logger.info 'Record: %s' % document.inspect
104
80
 
105
81
  documents.push(document)
106
82
  end
107
83
 
84
+ params = {}
85
+ if @commit
86
+ params[:commit] = true
87
+ end
88
+ params[:commitWithin] = @commitWithin
108
89
  if @mode == MODE_STANDALONE then
109
- @solr.add documents, :params => {:commit => true}
90
+ @solr.add documents, :params => params
110
91
  @logger.info 'Added %d document(s) to Solr' % documents.count
111
92
  elsif @mode == MODE_SOLRCLOUD then
112
- @solr.add documents, collection: @collection, :params => {:commit => true}
93
+ @solr.add documents, collection: @collection, :params => params
113
94
  @logger.info 'Added %d document(s) to Solr' % documents.count
114
95
  end
115
96
 
@@ -124,44 +105,4 @@ class LogStash::Outputs::Solr < LogStash::Outputs::Base
124
105
  end
125
106
  end # def close
126
107
 
127
- private
128
- def get_unique_key
129
- response = nil
130
-
131
- if @mode == MODE_STANDALONE then
132
- response = @solr.get 'schema/uniquekey'
133
- elsif @mode == MODE_SOLRCLOUD then
134
- response = @solr.get 'schema/uniquekey', collection: @collection
135
- end
136
-
137
- unique_key = response['uniqueKey']
138
- @logger.info 'Unique key: #{unique_key}'
139
-
140
- return unique_key
141
-
142
- rescue Exception => e
143
- @logger.warn("Unique key", :exception => e.inspect)
144
- end # def get_unique_key
145
-
146
- private
147
- def get_fields
148
- response = nil
149
-
150
- if @mode == MODE_STANDALONE then
151
- response = @solr.get 'schema/fields'
152
- elsif @mode == MODE_SOLRCLOUD then
153
- response = @solr.get 'schema/fields', collection: @collection
154
- end
155
-
156
- fields = []
157
- response['fields'].each do |field|
158
- fields.push(field['name'])
159
- end
160
- @logger.info 'Fields: #{fields}'
161
-
162
- return fields
163
-
164
- rescue Exception => e
165
- @logger.warn("Could not get fields", :exception => e.inspect)
166
- end # def get_fields
167
108
  end # class LogStash::Outputs::Solr
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-custom-solr'
3
- s.version = "0.1.5"
3
+ s.version = "0.1.6"
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."
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.add_runtime_dependency 'rsolr', '~> 1.1.2'
25
25
  s.add_runtime_dependency 'zk'
26
- s.add_runtime_dependency 'rsolr-cloud'
26
+ s.add_runtime_dependency 'rsolr-cloud-custom'
27
27
  s.add_runtime_dependency 'stud'
28
28
 
29
29
  s.add_development_dependency "logstash-core", ">= 1.60", "<= 2.99"
@@ -19,11 +19,9 @@ describe LogStash::Outputs::Solr do
19
19
  'url' => 'http://localhost:8983/solr/collection1',
20
20
  'zk_host' => 'localhost:2181/solr',
21
21
  'collection' => 'collection1',
22
- 'defined_fields' => ['id', 'title'],
23
- 'ignore_undefined_fields' => true,
24
- 'unique_key_field' => 'id',
25
- 'timestamp_field' => 'event_timestamp',
26
- 'flush_size' => 100
22
+ 'flush_size' => 100,
23
+ 'commit' => false,
24
+ 'commitWithin' => 10000
27
25
  }
28
26
  }
29
27
 
@@ -42,29 +40,19 @@ describe LogStash::Outputs::Solr do
42
40
  expect(output.config['collection']).to eq('collection1')
43
41
  end
44
42
 
45
- it 'defined_fields' do
46
- output = LogStash::Outputs::Solr.new(config)
47
- expect(output.config['defined_fields']).to eq(['id', 'title'])
48
- end
49
-
50
- it 'ignore_undefined_fields' do
51
- output = LogStash::Outputs::Solr.new(config)
52
- expect(output.config['ignore_undefined_fields']).to eq(true)
53
- end
54
-
55
- it 'unique_key_field' do
43
+ it 'flush_size' do
56
44
  output = LogStash::Outputs::Solr.new(config)
57
- expect(output.config['unique_key_field']).to eq('id')
45
+ expect(output.config['flush_size']).to eq(100)
58
46
  end
59
47
 
60
- it 'timestamp_field' do
48
+ it 'commit' do
61
49
  output = LogStash::Outputs::Solr.new(config)
62
- expect(output.config['timestamp_field']).to eq('event_timestamp')
50
+ expect(output.config['commit']).to eq(false)
63
51
  end
64
52
 
65
- it 'flush_size' do
53
+ it 'commitWithin' do
66
54
  output = LogStash::Outputs::Solr.new(config)
67
- expect(output.config['flush_size']).to eq(100)
55
+ expect(output.config['commitWithin']).to eq(10000)
68
56
  end
69
57
  end
70
58
 
@@ -72,10 +60,6 @@ describe LogStash::Outputs::Solr do
72
60
  let(:config) {
73
61
  {
74
62
  'url' => 'http://localhost:8983/solr/collection1',
75
- 'defined_fields' => ['id', 'title'],
76
- 'ignore_undefined_fields' => true,
77
- 'unique_key_field' => 'id',
78
- 'timestamp_field' => 'event_timestamp',
79
63
  'flush_size' => 100
80
64
  }
81
65
  }
@@ -102,10 +86,6 @@ describe LogStash::Outputs::Solr do
102
86
  {
103
87
  'zk_host' => 'localhost:3292/solr',
104
88
  'collection' => 'collection1',
105
- 'defined_fields' => ['id', 'title'],
106
- 'ignore_undefined_fields' => true,
107
- 'unique_key_field' => 'id',
108
- 'timestamp_field' => 'event_timestamp',
109
89
  'flush_size' => 100
110
90
  }
111
91
  }
@@ -123,10 +103,6 @@ describe LogStash::Outputs::Solr do
123
103
  let(:config) {
124
104
  {
125
105
  'url' => 'http://localhost:8983/solr/collection1',
126
- 'defined_fields' => ['id', 'title'],
127
- 'ignore_undefined_fields' => true,
128
- 'unique_key_field' => 'id',
129
- 'timestamp_field' => 'event_timestamp',
130
106
  'flush_size' => 100
131
107
  }
132
108
  }
@@ -159,10 +135,6 @@ describe LogStash::Outputs::Solr do
159
135
  {
160
136
  'zk_host' => 'localhost:3292/solr',
161
137
  'collection' => 'collection1',
162
- 'defined_fields' => ['id', 'title'],
163
- 'ignore_undefined_fields' => true,
164
- 'unique_key_field' => 'id',
165
- 'timestamp_field' => 'event_timestamp',
166
138
  'flush_size' => 100
167
139
  }
168
140
  }
@@ -194,15 +166,9 @@ describe LogStash::Outputs::Solr do
194
166
  zk = ZK.new('localhost:3292')
195
167
  delete_nodes(zk, '/solr')
196
168
  create_nodes(zk, '/solr/live_nodes')
197
- create_nodes(zk, '/solr/collections')
198
169
  ['localhost:8983_solr'].each do |node|
199
170
  zk.create("/solr/live_nodes/#{node}", '', mode: :ephemeral)
200
171
  end
201
- ['collection1'].each do |collection|
202
- zk.create("/solr/collections/#{collection}")
203
- json = File.read("spec/files/collections/#{collection}/state.json")
204
- zk.create("/solr/collections/#{collection}/state.json", json, mode: :ephemeral)
205
- end
206
172
  end
207
173
 
208
174
  def stop_zookeeper
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.5
4
+ version: 0.1.6
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-18 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -78,7 +78,7 @@ dependencies:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
- name: rsolr-cloud
81
+ name: rsolr-cloud-custom
82
82
  prerelease: false
83
83
  type: :runtime
84
84
  version_requirements: !ruby/object:Gem::Requirement
@@ -177,7 +177,6 @@ files:
177
177
  - README.md
178
178
  - lib/logstash/outputs/solr.rb
179
179
  - logstash-output-custom-solr.gemspec
180
- - spec/files/collections/collection1/state.json
181
180
  - spec/outputs/solr_spec.rb
182
181
  homepage: https://github.com/mosuka/logstash-output-solr
183
182
  licenses:
@@ -206,5 +205,4 @@ signing_key:
206
205
  specification_version: 4
207
206
  summary: Logstash output plugin for sending data to Solr.
208
207
  test_files:
209
- - spec/files/collections/collection1/state.json
210
208
  - spec/outputs/solr_spec.rb
@@ -1,14 +0,0 @@
1
- {"collection1":{
2
- "replicationFactor":"1",
3
- "router":{"name":"compositeId"},
4
- "maxShardsPerNode":"1",
5
- "autoAddReplicas":"false",
6
- "shards":{"shard1":{
7
- "range":"80000000-7fffffff",
8
- "state":"active",
9
- "replicas":{"core_node1":{
10
- "core":"collection1_shard1_replica1",
11
- "base_url":"http://localhost:8983/solr",
12
- "node_name":"localhost:8983_solr",
13
- "state":"active",
14
- "leader":"true"}}}}}}