It was said that there is no equivalent to HLRC BulkProcessor
in the new elasticsearch Java API client BUT there are these BulkOperation
, BulkRequest
, BulkResponse
...are they similar in a way?
Hi @ALX_DM .
I have an example that bulk where I read a list of documents in json file and create a bulkrequest to index in my index.
var in = getClass().getClassLoader().getResourceAsStream("dataset.json");
var dataset = new String(ByteStreams.toByteArray(in), StandardCharsets.UTF_8);
var objectMapper = new ObjectMapper();
var movies = objectMapper.readValue(dataset, new TypeReference<List<Movie>>() {
});
BulkRequest.Builder br = new BulkRequest.Builder();
movies.forEach(movie -> {
br.operations(op -> op
.index(idx -> idx
.index("idx_test")
.document(movie)
)
);
});
var response = client.bulk(br.build());
Thank you for this sample.
THis will indeed guide me in the right direction.
Very much appreciated.
1 Like
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.