Skip to content

Clean up semantic text field mapper tests #127853

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

Merged

Conversation

Mikep86
Copy link
Contributor

@Mikep86 Mikep86 commented May 7, 2025

Fix issues identified in #126629:

  • Ensure all mappers are correctly propagating index version
  • Cleanup testIsEnabled and remove code that was necessary for those tests to pass

@Mikep86 Mikep86 requested review from jimczi and kderusso May 7, 2025 19:12
@Mikep86 Mikep86 added >non-issue auto-backport Automatically create backport pull requests when merged :SearchOrg/Relevance Label for the Search (solution/org) Relevance team v8.19.0 v9.1.0 labels May 7, 2025
@elasticsearchmachine elasticsearchmachine added Team:SearchOrg Meta label for the Search Org (Enterprise Search) Team:Search - Relevance The Search organization Search Relevance team labels May 7, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/search-eng (Team:SearchOrg)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/search-relevance (Team:Search - Relevance)

@Mikep86 Mikep86 added >test Issues or PRs that are addressing/adding tests and removed >non-issue labels May 7, 2025
Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@kderusso kderusso left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for cleaning this up. Left one nitpick, non-blocking.

.build();
assertTrue(InferenceMetadataFieldsMapper.isEnabled(settings));

// Test that index.mapping.semantic_text.use_legacy_format == false is ignored when the index version is too old to support the new
Copy link
Member

Choose a reason for hiding this comment

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

Out of the scope of this PR: Is it technically correct that we don't error in this case, since we're requesting a format that can't be applied?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps not, but it's a moot point now as erroring out on old index versions could be a breaking change. Add into that that this is an index setting that should not be used externally and it just doesn't seem worth following up on.

IndexVersionUtils.randomVersionBetween(
random(),
IndexVersions.SEMANTIC_TEXT_FIELD_TYPE,
IndexVersionUtils.getPreviousVersion(IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: We're starting to get a little confusing with index versions as the names aren't always clear what the change was. Would it make sense to do a favor to our future selves and future maintainers, since we're cleaning up anyway, to create private members to use for testing? e.g.

private static final IndexVersion INDEX_VERSION_THAT_WE_INTRODUCED_NEW_FORMAT  = ... 
... 

Naming for illustrative purposes only, I'm sure there are better ones, but you get the drift 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the comments more descriptive here, I think that has the same effect. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

I still think readability would be enhanced by better names, but the comments are better, thanks for adding them

} else {
return createMapperService(settings, mappings);
}
return createMapperService(indexVersion, settings, mappings);
Copy link
Member

Choose a reason for hiding this comment

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

❤️ Thanks for the cleanup

@Mikep86
Copy link
Contributor Author

Mikep86 commented May 8, 2025

@elasticmachine update branch

@Mikep86 Mikep86 merged commit 9e542c0 into elastic:main May 8, 2025
17 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 127853

@Mikep86
Copy link
Contributor Author

Mikep86 commented May 8, 2025

💚 All backports created successfully

Status Branch Result
8.19

Questions ?

Please refer to the Backport tool documentation

Mikep86 added a commit to Mikep86/elasticsearch that referenced this pull request May 8, 2025
(cherry picked from commit 9e542c0)

# Conflicts:
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
elasticsearchmachine pushed a commit that referenced this pull request May 8, 2025
* Clean up semantic text field mapper tests (#127853)

(cherry picked from commit 9e542c0)

# Conflicts:
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java

* Fix getRandomCompatibleIndexVersion
ywangd pushed a commit to ywangd/elasticsearch that referenced this pull request May 9, 2025
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged :SearchOrg/Relevance Label for the Search (solution/org) Relevance team Team:Search - Relevance The Search organization Search Relevance team Team:SearchOrg Meta label for the Search Org (Enterprise Search) >test Issues or PRs that are addressing/adding tests v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants