-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Pull match_only_text fixes into main #130049
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
jordan-powers
merged 7 commits into
elastic:main
from
jordan-powers:fix-match-only-text
Jun 26, 2025
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
99ee7ab
Fix BWC in match_only_text (#130020)
jordan-powers 659aae5
Merge remote-tracking branch 'upstream/patch/serverless-fix' into fix…
jordan-powers 52644ea
Address review nits
jordan-powers 78a9929
Use instanceof implicit casting
jordan-powers 31c6392
Use toString instead of string cast
jordan-powers 41ed0f0
Merge remote-tracking branch 'upstream/main' into fix-match-only-text
jordan-powers 4da3c7e
Merge remote-tracking branch 'upstream/main' into fix-match-only-text
jordan-powers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -362,10 +362,37 @@ public Query phrasePrefixQuery(TokenStream stream, int slop, int maxExpansions, | |
| return toQuery(query, queryShardContext); | ||
| } | ||
|
|
||
| private static class BytesFromMixedStringsBytesRefBlockLoader extends BlockStoredFieldsReader.StoredFieldsBlockLoader { | ||
| BytesFromMixedStringsBytesRefBlockLoader(String field) { | ||
| super(field); | ||
| } | ||
|
|
||
| @Override | ||
| public Builder builder(BlockFactory factory, int expectedCount) { | ||
| return factory.bytesRefs(expectedCount); | ||
| } | ||
|
|
||
| @Override | ||
| public RowStrideReader rowStrideReader(LeafReaderContext context) throws IOException { | ||
| return new BlockStoredFieldsReader.Bytes(field) { | ||
| private final BytesRef scratch = new BytesRef(); | ||
|
|
||
| @Override | ||
| protected BytesRef toBytesRef(Object v) { | ||
| if (v instanceof BytesRef) { | ||
| return (BytesRef) v; | ||
| } else { | ||
| return BlockSourceReader.toBytesRef(scratch, (String) v); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public BlockLoader blockLoader(BlockLoaderContext blContext) { | ||
| if (textFieldType.isSyntheticSource()) { | ||
| return new BlockStoredFieldsReader.BytesFromBytesRefsBlockLoader(storedFieldNameForSyntheticSource()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before I forget. In a follow up, let's add index version for this? So that we can only use |
||
| return new BytesFromMixedStringsBytesRefBlockLoader(storedFieldNameForSyntheticSource()); | ||
| } | ||
| SourceValueFetcher fetcher = SourceValueFetcher.toString(blContext.sourcePaths(name())); | ||
| // MatchOnlyText never has norms, so we have to use the field names field | ||
|
|
@@ -386,7 +413,12 @@ public IndexFieldData.Builder fielddataBuilder(FieldDataContext fieldDataContext | |
| ) { | ||
| @Override | ||
| protected BytesRef storedToBytesRef(Object stored) { | ||
| return (BytesRef) stored; | ||
| if (stored instanceof BytesRef storedBytes) { | ||
| return storedBytes; | ||
| } else { | ||
| assert stored instanceof String; | ||
| return new BytesRef(stored.toString()); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
@@ -477,7 +509,12 @@ protected SyntheticSourceSupport syntheticSourceSupport() { | |
| () -> new StringStoredFieldFieldLoader(fieldType().storedFieldNameForSyntheticSource(), fieldType().name(), leafName()) { | ||
| @Override | ||
| protected void write(XContentBuilder b, Object value) throws IOException { | ||
| b.value(((BytesRef) value).utf8ToString()); | ||
| if (value instanceof BytesRef valueBytes) { | ||
| b.value(valueBytes.utf8ToString()); | ||
| } else { | ||
| assert value instanceof String; | ||
| b.value(value.toString()); | ||
| } | ||
| } | ||
| } | ||
| ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.