Skip to content

Support AggregationUpdate / UpdateSpecification on Bulk API #3872

Closed
@IsNull

Description

@IsNull

We want to use BulkOperations with AggregationUpdates.

Currently, BulkOperations defines its API like below, using Update and not UpdateDefinition.

public interface BulkOperations {


	/**
	 * Add a list of updates to the bulk operation. For each update request, only the first matching document is updated.
	 *
	 * @param updates Update operations to perform.
	 * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
	 */
	BulkOperations updateOne(List<Pair<Query, Update>> updates);

	/**
	 * Add a single update to the bulk operation. For the update request, all matching documents are updated.
	 *
	 * @param query Update criteria.
	 * @param update Update operation to perform.
	 * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
	 */
	BulkOperations updateMulti(Query query, Update update);

	/**
	 * Add a list of updates to the bulk operation. For each update request, all matching documents are updated.
	 *
	 * @param updates Update operations to perform.
	 * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
	 */
	BulkOperations updateMulti(List<Pair<Query, Update>> updates);

	/**
	 * Add a single upsert to the bulk operation. An upsert is an update if the set of matching documents is not empty,
	 * else an insert.
	 *
	 * @param query Update criteria.
	 * @param update Update operation to perform.
	 * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
	 */
	BulkOperations upsert(Query query, Update update);

	/**
	 * Add a list of upserts to the bulk operation. An upsert is an update if the set of matching documents is not empty,
	 * else an insert.
	 *
	 * @param updates Updates/insert operations to perform.
	 * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
	 */
	BulkOperations upsert(List<Pair<Query, Update>> updates);

}

Looking at the code and usage, this could be switched to UpdateDefinition and thus be more generic.

Background is, that we want to use AggregationUpdate with the bulk api and this class does only implement UpdateDefinition and not extend Update.

Proposal:

BulkOperations upsert(List<Pair<Query, Update>> updates);

should become

<U extends UpdateDefinition> BulkOperations upsert(List<Pair<Query, U>> updates);

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions