Bulk update with java API

(Marek K) #1


So I'm trying to index multiple documents using Bulk API in java.

My documents are valid (I checked if I can index them one by one - and it works).

The bulk API also works - partially, because from 169 documents, only 3 are indexed. Ids of my documents are unique.
This is how I'm building BulkProcessor:

BulkProcessor.builder(client, new BulkProcessor.Listener() {
		public void beforeBulk(long executionId, BulkRequest request) {

		public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {

		public void afterBulk(long executionId, BulkRequest request, Throwable failure) {
          .setBulkSize(new ByteSizeValue(500, ByteSizeUnit.MB))

And this is how I add my documents to bulkProcessor:


What I'm doing step by step:

  1. Check if index with given name exists
  2. If it is, remove it
  3. Create new index
  4. Wait for cluster green status
  5. Create BulkProcessor
  6. Add indexRequests to bulkProcessor
  7. Close BulkProcessor
  8. Wait for Cluster green status
  9. Send refresh request
  10. Remove index with alias "indexaliasName"
  11. Add indexAliasName to index which was created in point number 3.

Any ideas what can be the reason of adding only three documents? Instead of 160 ?

(David Pilato) #2

I'd trace results in both afterBulk methods to check what is happening.

(Marek K) #3

Ehh, sorry for bothering. I did very terrible mistake.

My Models which I used were not new objects, so in fact I had a list of three modeles repeated many times.

Everything works now when I'm creating new Object per document of course..

(system) #4