-
Notifications
You must be signed in to change notification settings - Fork 192
[Feature] PPL Highlight Support #5234
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
RyanL1997
merged 25 commits into
opensearch-project:main
from
RyanL1997:ppl-highlight-cmd
Mar 19, 2026
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0686753
initial commit for highlight cmd
RyanL1997 f8f7208
fix the response format
RyanL1997 4c649b5
pushdown fix (similar to v2)
RyanL1997 a596cba
fix - filter out highlight col in result schema
RyanL1997 5c64e04
add docs for highlight
RyanL1997 49f5598
dead code cleanup
RyanL1997 fec921d
enable no pushdown
RyanL1997 a5a2788
fix pushdown and add IT and explain IT
RyanL1997 f46b241
add more tests for coverage
RyanL1997 90839b6
add ccr tests
RyanL1997 e38284d
fix ccr test
RyanL1997 3cfbe9a
[GRAMMAR REMOVAL] Internally handle highlight instead of expose as a …
RyanL1997 9a272c4
Add more tests
RyanL1997 d039af6
Update the doc
RyanL1997 82443d8
fix doc test
RyanL1997 124c42a
fix IT
RyanL1997 c87b5b8
fix tests
RyanL1997 f3939c6
peng - align with lucene opensearch for request intake
RyanL1997 9b99296
peng - set the default fragment size to 100
RyanL1997 87bb284
peng - update the doc to reflect the changes
RyanL1997 1b07536
Peng - drop the AST layer implementation and address the comments.
RyanL1997 1bd30fa
peng - add more IT for highlight cases
RyanL1997 e2ef1b2
chen - update doc
RyanL1997 d289025
review - make highlight embeded into datarows/schemas
RyanL1997 08d3c20
fix security IT
RyanL1997 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
48 changes: 48 additions & 0 deletions
48
core/src/main/java/org/opensearch/sql/ast/tree/HighlightConfig.java
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.sql.ast.tree; | ||
|
|
||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Bundles highlight configuration: field names (or wildcards) with per-field options, and optional | ||
| * global pre/post tags and fragment size. Supports both the simple array format ({@code ["*"]}) and | ||
| * the rich OSD object format with {@code pre_tags}, {@code post_tags}, {@code fields}, and {@code | ||
| * fragment_size}. | ||
| * | ||
| * <p>The {@code fields} map keys are field names or wildcards; the values are per-field option maps | ||
| * that are passed through to the OpenSearch highlight builder (e.g. {@code fragment_size}, {@code | ||
| * number_of_fragments}, {@code type}). | ||
| */ | ||
| public record HighlightConfig( | ||
| Map<String, Map<String, Object>> fields, | ||
| List<String> preTags, | ||
| List<String> postTags, | ||
| Integer fragmentSize) { | ||
|
|
||
| /** Convenience constructor for the simple array format (fields only, no tag/size overrides). */ | ||
| public HighlightConfig(List<String> fieldNames) { | ||
| this(toFieldMap(fieldNames), null, null, null); | ||
| } | ||
|
|
||
| /** Returns the field names as a list (for display and iteration). */ | ||
| public List<String> fieldNames() { | ||
| return fields == null ? List.of() : List.copyOf(fields.keySet()); | ||
| } | ||
|
|
||
| private static Map<String, Map<String, Object>> toFieldMap(List<String> fieldNames) { | ||
| if (fieldNames == null) { | ||
| return null; | ||
| } | ||
| Map<String, Map<String, Object>> map = new LinkedHashMap<>(); | ||
| for (String name : fieldNames) { | ||
| map.put(name, Map.of()); | ||
| } | ||
| return map; | ||
| } | ||
| } |
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
18 changes: 18 additions & 0 deletions
18
core/src/main/java/org/opensearch/sql/calcite/plan/HighlightPushDown.java
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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.sql.calcite.plan; | ||
|
|
||
| import org.apache.calcite.rel.RelNode; | ||
| import org.opensearch.sql.ast.tree.HighlightConfig; | ||
|
|
||
| /** | ||
| * Interface for scan nodes that support highlight pushdown. Highlight is a scan hint (not a | ||
| * relational operator), so it is pushed down eagerly during plan construction rather than via an | ||
| * optimizer rule. | ||
| */ | ||
| public interface HighlightPushDown { | ||
| RelNode pushDownHighlight(HighlightConfig highlightConfig); | ||
| } |
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: If a third request-level parameter is added (timeout, routing, preference), that's the time to refactor to QueryOptions — the pattern exists (ExecutionContext, PlanContext), and it's a straightforward migration. No need to speculate now.