Get Failure keys in bulk operation

Hi I am doing the insert bulk operation.

	List<JsonDocument> success = Collections.synchronizedList(new ArrayList<JsonDocument>());
			Observable
				.from(documents)
				.flatMap(document -> connection.getBucket().async().insert(document))
				.doOnNext(doc -> success.add(doc))
				.doOnError(err -> logger.error("Labham -", err))
				.last()
				.toBlocking()
		        .single();

In the above method, I am able to create successfully list of success in inserting document but is there a way so that i can create a map<key, Throwable> failure; so that for the failed docs i can map them to there whatever exception is thrown by couchbase.

Couchbase - 4.1.0-5005 Community Edition Java. 1.8 and couchbase-Client --> 2.4.3

We do this to track how we do gets that fail. You could do something similar.

        Map<K, CouchbaseOperationResult<T>> results = new HashMap<>(keys.size());

        for (K k : keys) {
            String cbKey = getKeyProvider().getCouchbaseKey(k);
            keyLookups.put(cbKey, k);
        }

        // See: http://docs.couchbase.com/developer/java-2.1/documents-bulk.html
        List<JsonDocument> foundDocs = Observable
                .from(keyLookups.keySet())
                .compose(o -> o.flatMap(getCouchProvider().getBucket().async()::get))
                .toList()
                .toBlocking()
                .single();

        for (Document jsonDocument : foundDocs) {
            K key = keyLookups.remove(jsonDocument.id());
            results.put(key, createEntityResult(jsonDocument));
        }

        for (K keyAddMissing : keyLookups.values()) {
            results.put(keyAddMissing, createEntityResult(null));
        }

        return results;