Skip to content

Support AggregationUpdate / UpdateSpecification on Bulk API #3872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
IsNull opened this issue Nov 5, 2021 · 1 comment
Closed

Support AggregationUpdate / UpdateSpecification on Bulk API #3872

IsNull opened this issue Nov 5, 2021 · 1 comment
Assignees
Labels
theme: 4.0 type: enhancement A general enhancement

Comments

@IsNull
Copy link

IsNull commented Nov 5, 2021

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);

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 5, 2021
@IsNull IsNull changed the title Allow UpdateSpecification on Bulk API Support AggregationUpdate / UpdateSpecification on Bulk API Nov 5, 2021
@christophstrobl christophstrobl self-assigned this Nov 8, 2021
@christophstrobl christophstrobl added type: enhancement A general enhancement theme: 4.0 and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 8, 2021
@sebastianhaberey
Copy link

+1 for supporting AggregationUpdate here, it would definitely have helped me in my current project.

@mp911de mp911de added this to the 4.1 RC1 (2023.0.0) milestone Apr 14, 2023
mp911de added a commit that referenced this issue Apr 14, 2023
Refine updateOne/updateMulti signatures to accept UpdateDefinition in the generic signature. Use pattern variables and records where applicable. Resolve code duplicates.

See #3872
Original pull request: #4344
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: 4.0 type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants