Skip to content

Conversation

@jordan-powers
Copy link
Contributor

@jordan-powers jordan-powers commented Jun 25, 2025

This patch updates places that expect the match_only_text stored field to be stored as a BytesRef to instead perform an instanceof check and see if it's a string or BytesRef.

@jordan-powers jordan-powers self-assigned this Jun 25, 2025
@jordan-powers jordan-powers added >bug auto-backport Automatically create backport pull requests when merged :StorageEngine/Mapping The storage related side of mappings v8.19.0 v9.1.0 labels Jun 25, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @jordan-powers, I've created a changelog YAML for you.

@jordan-powers jordan-powers force-pushed the fix-bwc-match-only-text branch from 87260f6 to 33d2e3a Compare June 25, 2025 16:31
@elasticsearchmachine
Copy link
Collaborator

Hi @jordan-powers, I've created a changelog YAML for you.

@jordan-powers jordan-powers force-pushed the fix-bwc-match-only-text branch from 6c0aacf to a382ba6 Compare June 25, 2025 16:34
@jordan-powers jordan-powers marked this pull request as ready for review June 25, 2025 16:37
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@jordan-powers jordan-powers changed the base branch from main to patch/serverless-fix June 25, 2025 17:39
@jordan-powers jordan-powers requested a review from a team as a code owner June 25, 2025 17:39
@jordan-powers jordan-powers force-pushed the fix-bwc-match-only-text branch from 0daf1c7 to 1d285b1 Compare June 25, 2025 17:39
@martijnvg martijnvg requested a review from a team as a code owner June 25, 2025 18:09
@jordan-powers jordan-powers removed the auto-backport Automatically create backport pull requests when merged label Jun 25, 2025
Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

I left minor comments. These can be fixed in follow up

if (stored instanceof BytesRef) {
return (BytesRef) stored;
} else {
return new BytesRef((String) stored);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return new BytesRef((String) stored);
assert stored instances String
return new BytesRef(stored.toString());

Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe use BytesRefs#toBytesRef

Comment on lines +389 to +390
if (stored instanceof BytesRef) {
return (BytesRef) stored;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (stored instanceof BytesRef) {
return (BytesRef) stored;
if (stored instanceof BytesRef storedBytes) {
return storedBytes;

Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe use BytesRefs#toString

@Override
protected void write(XContentBuilder b, Object value) throws IOException {
b.value(((BytesRef) value).utf8ToString());
if (value instanceof BytesRef) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here?

}
}

public static class BytesFromMixedStringsBytesRefBlockLoader extends StoredFieldsBlockLoader {
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 can be moved to mapper-extras module then we can make this package protected and control its usage. Given that normally this class shouldn't be used. It just now a workaround for a bwc bug.

Copy link
Member

@dnhatn dnhatn 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 Jordan!

@jordan-powers
Copy link
Contributor Author

2 checks are failing: elasticsearch-ci/pr-upgrade and elasticsearch-ci/8.19.0 / Part 2 / bwc-snapshots. The first is a build script issue that the delivery folks are aware of, and the second is a failing test that's muted on main (#130010). Neither is a blocking issue, so I'll bypass the validation and merge.

@jordan-powers jordan-powers merged commit 99ee7ab into elastic:patch/serverless-fix Jun 25, 2025
23 of 27 checks passed
jordan-powers added a commit that referenced this pull request Jun 26, 2025
This brings in the fixes from #130020, with minor fixes to address review
nits from that PR.

Co-authored-by: Martijn van Groningen <[email protected]>
jordan-powers added a commit to jordan-powers/elasticsearch that referenced this pull request Jun 26, 2025
This brings in the fixes from elastic#130020, with minor fixes to address review
nits from that PR.

Co-authored-by: Martijn van Groningen <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Jun 27, 2025
* Pull match_only_text fixes into main (#130049)

This brings in the fixes from #130020, with minor fixes to address review
nits from that PR.

Co-authored-by: Martijn van Groningen <[email protected]>
(cherry picked from commit 40a7d02)

# Conflicts:
#	qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/MatchOnlyTextRollingUpgradeIT.java

* Fix base class of MatchOnlyTextRollingUpgradeIT

* Add missing assumption to MatchOnlyTextRollingUpgradeIT
smalyshev pushed a commit to smalyshev/elasticsearch that referenced this pull request Jun 27, 2025
This brings in the fixes from elastic#130020, with minor fixes to address review
nits from that PR.

Co-authored-by: Martijn van Groningen <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Jun 27, 2025
This brings in the fixes from #130020, with minor fixes to address review
nits from that PR.

Co-authored-by: Martijn van Groningen <[email protected]>
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 3, 2025
This brings in the fixes from elastic#130020, with minor fixes to address review
nits from that PR.

Co-authored-by: Martijn van Groningen <[email protected]>
@jordan-powers jordan-powers deleted the fix-bwc-match-only-text branch July 28, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants