Skip to content

Conversation

@stu-elastic
Copy link
Contributor

The _version metadata field should always exist in the sourceAndMetadata
map, this change enforces that invariant but allows tests to avoid it
if necessary.

Refs: #87309

The `_version` metadata field should always exist in the sourceAndMetadata
map, this change enforces that invariant but allows tests to avoid it
if necessary.

Refs: elastic#87309
@stu-elastic stu-elastic added WIP :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >refactoring labels Jun 28, 2022
@stu-elastic
Copy link
Contributor Author

@elasticsearch run elasticsearch-ci/part-1

@stu-elastic stu-elastic marked this pull request as ready for review June 28, 2022 20:03
@elasticmachine elasticmachine added Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team labels Jun 28, 2022
@stu-elastic stu-elastic requested a review from rjernst June 28, 2022 20:03
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple naming suggestions

/**
* Create an {@link IngestDocument} with {@link #DEFAULT_VERSION} as the _version metadata, if _version is not already present.
*/
public static IngestDocument ofSourceAndMetadataWithDefaultVersion(Map<String, Object> sourceAndMetadata) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the common case, can we shorten the method name to the original name? These are extremely long...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ofSourceAndMetadataWithDefaultVersion -> withDefaultVersion
ofSourceAndMetadataWithNullableVersion -> withNullableVersion
ofSourceAndIngestWithNullableVersion -> ofIngestWithNullableVersion
emptyIngestDocumentWithDefaultVersion -> emptyIngestDocument

*/
public static IngestDocument emptyIngestDocument() {
return new IngestDocument(new HashMap<>(), new HashMap<>());
public static IngestDocument emptyIngestDocumentWithDefaultVersion() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be fine to leave the original name and just add to the javadoc that the default version is added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept original, added javadoc comment.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better names, thanks! LGTM

@stu-elastic
Copy link
Contributor Author

stu-elastic commented Jun 29, 2022

The discussions of the BWC issues happened in this thread: #87309 (comment), leading to this change.

@stu-elastic stu-elastic merged commit d945fce into elastic:master Jun 29, 2022
stu-elastic added a commit that referenced this pull request Jun 29, 2022
…ersion (#88183)

When `RandomDocumentPicks.randomExistingFieldName` selects a field, the
caller expects to be able to manipulate that field in any manner.  `_version` has
special validation, must fit in an `long` and may not be `null`.

This change no longer returns `_version` from `randomExistingFieldName` unless it is the only field in the document.

Related to change: #88102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >refactoring Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team v8.4.0 WIP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants