embulk-output-elasticsearch 0.1.2 → 0.1.3
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77e76440b56eee33e80dfce250dce8209c3a9831
|
4
|
+
data.tar.gz: 6ac309248b002ce2cd34d27078ed9f7fbde854ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55339564362bc859925dd0e8f79c0d4b5cec268f901b3145c0920b865eab8abc804af39c2e5ddbf37ca07f9370e74d350beeb6f4fb4e82f484bd8498ee1a1f9d
|
7
|
+
data.tar.gz: ee5114f6ead0fd0d89353f5cc9717b83c383758bed77f739b361800371fb5d31f6f952295481ea083b80080c2db7c69deb05f02474b8618b957a17f3420e58c6
|
data/build.gradle
CHANGED
@@ -37,9 +37,12 @@ import org.embulk.spi.TransactionalPageOutput;
|
|
37
37
|
import org.slf4j.Logger;
|
38
38
|
|
39
39
|
import java.io.IOException;
|
40
|
+
import java.util.Date;
|
40
41
|
import java.util.List;
|
41
42
|
import java.util.concurrent.TimeUnit;
|
42
43
|
|
44
|
+
import static com.google.common.base.Preconditions.checkState;
|
45
|
+
|
43
46
|
public class ElasticsearchOutputPlugin
|
44
47
|
implements OutputPlugin
|
45
48
|
{
|
@@ -60,15 +63,15 @@ public class ElasticsearchOutputPlugin
|
|
60
63
|
@Config("nodes")
|
61
64
|
public List<NodeAddressTask> getNodes();
|
62
65
|
|
63
|
-
@Config("
|
66
|
+
@Config("index")
|
64
67
|
public String getIndex();
|
65
68
|
|
66
69
|
@Config("index_type")
|
67
|
-
public String
|
70
|
+
public String getType();
|
68
71
|
|
69
|
-
@Config("
|
72
|
+
@Config("id")
|
70
73
|
@ConfigDefault("null")
|
71
|
-
public Optional<String>
|
74
|
+
public Optional<String> getId();
|
72
75
|
|
73
76
|
@Config("bulk_actions")
|
74
77
|
@ConfigDefault("1000")
|
@@ -94,9 +97,22 @@ public class ElasticsearchOutputPlugin
|
|
94
97
|
{
|
95
98
|
final RunnerTask task = config.loadConfig(RunnerTask.class);
|
96
99
|
|
100
|
+
// confirm that a client can be initialized
|
97
101
|
try (Client client = createClient(task)) {
|
98
102
|
}
|
99
103
|
|
104
|
+
// check that id is included in the schema or not if the id is not null.
|
105
|
+
if (task.getId().isPresent()) {
|
106
|
+
String id = task.getId().get();
|
107
|
+
boolean found = false;
|
108
|
+
for (Column column : schema.getColumns()) {
|
109
|
+
if (column.equals(id)) {
|
110
|
+
found = true;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
checkState(found, "id is not included in column names of the Schema.");
|
114
|
+
}
|
115
|
+
|
100
116
|
try {
|
101
117
|
control.run(task.dump());
|
102
118
|
} catch (Exception e) {
|
@@ -199,8 +215,8 @@ public class ElasticsearchOutputPlugin
|
|
199
215
|
private PageReader pageReader;
|
200
216
|
|
201
217
|
private final String index;
|
202
|
-
private final String
|
203
|
-
private final String
|
218
|
+
private final String type;
|
219
|
+
private final String id;
|
204
220
|
|
205
221
|
ElasticsearchPageOutput(RunnerTask task, Client client, BulkProcessor bulkProcessor)
|
206
222
|
{
|
@@ -210,8 +226,8 @@ public class ElasticsearchOutputPlugin
|
|
210
226
|
this.bulkProcessor = bulkProcessor;
|
211
227
|
|
212
228
|
this.index = task.getIndex();
|
213
|
-
this.
|
214
|
-
this.
|
229
|
+
this.type = task.getType();
|
230
|
+
this.id = task.getId().orNull();
|
215
231
|
}
|
216
232
|
|
217
233
|
void open(final Schema schema)
|
@@ -282,7 +298,15 @@ public class ElasticsearchOutputPlugin
|
|
282
298
|
|
283
299
|
@Override
|
284
300
|
public void timestampColumn(Column column) {
|
285
|
-
|
301
|
+
try {
|
302
|
+
contextBuilder.field(column.getName(), new Date(pageReader.getTimestamp(column).toEpochMilli()));
|
303
|
+
} catch (IOException e) {
|
304
|
+
try {
|
305
|
+
contextBuilder.nullField(column.getName());
|
306
|
+
} catch (IOException ex) {
|
307
|
+
throw Throwables.propagate(ex);
|
308
|
+
}
|
309
|
+
}
|
286
310
|
}
|
287
311
|
});
|
288
312
|
|
@@ -297,7 +321,7 @@ public class ElasticsearchOutputPlugin
|
|
297
321
|
|
298
322
|
private IndexRequest newIndexRequest()
|
299
323
|
{
|
300
|
-
return Requests.indexRequest(index).type(
|
324
|
+
return Requests.indexRequest(index).type(type).id(id);
|
301
325
|
}
|
302
326
|
|
303
327
|
@Override
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muga Nishizawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,11 +69,10 @@ files:
|
|
69
69
|
- lib/embulk/output/elasticsearch.rb
|
70
70
|
- settings.gradle
|
71
71
|
- src/main/java/org/embulk/output/ElasticsearchOutputPlugin.java
|
72
|
-
- src/main/java/org/embulk/output/ElasticsearchOutputPluginModule.java
|
73
72
|
- src/main/resources/META-INF/services/org.embulk.spi.Extension
|
74
73
|
- src/test/java/org/embulk/output/TestElasticsearchOutputPlugin.java
|
75
74
|
- classpath/elasticsearch-1.4.2.jar
|
76
|
-
- classpath/embulk-output-elasticsearch-0.1.
|
75
|
+
- classpath/embulk-output-elasticsearch-0.1.3.jar
|
77
76
|
- classpath/lucene-analyzers-common-4.10.2.jar
|
78
77
|
- classpath/lucene-core-4.10.2.jar
|
79
78
|
- classpath/lucene-grouping-4.10.2.jar
|
@@ -1,31 +0,0 @@
|
|
1
|
-
package org.embulk.output;
|
2
|
-
|
3
|
-
import com.google.common.base.Preconditions;
|
4
|
-
import com.google.common.collect.ImmutableList;
|
5
|
-
import com.google.inject.Binder;
|
6
|
-
import com.google.inject.Module;
|
7
|
-
import org.embulk.config.ConfigSource;
|
8
|
-
import org.embulk.spi.Extension;
|
9
|
-
import org.embulk.spi.OutputPlugin;
|
10
|
-
|
11
|
-
import java.util.List;
|
12
|
-
|
13
|
-
import static org.embulk.plugin.InjectedPluginSource.registerPluginTo;
|
14
|
-
|
15
|
-
public class ElasticsearchOutputPluginModule
|
16
|
-
implements Extension, Module
|
17
|
-
{
|
18
|
-
|
19
|
-
@Override
|
20
|
-
public void configure(Binder binder)
|
21
|
-
{
|
22
|
-
Preconditions.checkNotNull(binder, "binder is null.");
|
23
|
-
registerPluginTo(binder, OutputPlugin.class, "elasticsearch", ElasticsearchOutputPlugin.class);
|
24
|
-
}
|
25
|
-
|
26
|
-
@Override
|
27
|
-
public List<Module> getModules(ConfigSource systemConfig)
|
28
|
-
{
|
29
|
-
return ImmutableList.<Module>of(this);
|
30
|
-
}
|
31
|
-
}
|