-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add verbose pipeline parameter to output each processor's execution details #16843
base: main
Are you sure you want to change the base?
Changes from all commits
1c3b946
d931750
1f879c1
488377f
e4e30f5
615a4b6
0ae4d06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,7 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R | |
public static final ParseField SLICE = new ParseField("slice"); | ||
public static final ParseField POINT_IN_TIME = new ParseField("pit"); | ||
public static final ParseField SEARCH_PIPELINE = new ParseField("search_pipeline"); | ||
public static final ParseField VERBOSE_SEARCH_PIPELINE = new ParseField("verbose_pipeline"); | ||
|
||
public static SearchSourceBuilder fromXContent(XContentParser parser) throws IOException { | ||
return fromXContent(parser, true); | ||
|
@@ -226,6 +227,8 @@ public static HighlightBuilder highlight() { | |
|
||
private String searchPipeline; | ||
|
||
private boolean verbosePipeline; | ||
|
||
/** | ||
* Constructs a new search source builder. | ||
*/ | ||
|
@@ -302,6 +305,9 @@ public SearchSourceBuilder(StreamInput in) throws IOException { | |
if (in.getVersion().onOrAfter(Version.V_2_18_0)) { | ||
searchPipeline = in.readOptionalString(); | ||
} | ||
if (in.getVersion().onOrAfter(Version.CURRENT)) { | ||
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. I think you need to have exact version here, CURRENT will change with every next release |
||
verbosePipeline = in.readBoolean(); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -385,6 +391,9 @@ public void writeTo(StreamOutput out) throws IOException { | |
if (out.getVersion().onOrAfter(Version.V_2_18_0)) { | ||
out.writeOptionalString(searchPipeline); | ||
} | ||
if (out.getVersion().onOrAfter(Version.CURRENT)) { | ||
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. same as in previous comment |
||
out.writeOptionalBoolean(verbosePipeline); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -1142,6 +1151,26 @@ public SearchSourceBuilder pipeline(String searchPipeline) { | |
return this; | ||
} | ||
|
||
/** | ||
* Enables or disables verbose mode for the search pipeline. | ||
* | ||
* When verbose mode is enabled, detailed information about each processor | ||
* in the search pipeline is included in the search response. This includes | ||
* the processor name, execution status, input, output, and time taken for processing. | ||
* | ||
* This parameter is primarily intended for debugging purposes, allowing users | ||
* to track how data flows and transforms through the search pipeline. | ||
* | ||
*/ | ||
public SearchSourceBuilder verbosePipeline(boolean verbosePipeline) { | ||
this.verbosePipeline = verbosePipeline; | ||
return this; | ||
} | ||
|
||
public Boolean verbosePipeline() { | ||
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. why return type is a wrapper around primitive Boolean? |
||
return verbosePipeline; | ||
} | ||
|
||
/** | ||
* Rewrites this search source builder into its primitive form. e.g. by | ||
* rewriting the QueryBuilder. If the builder did not change the identity | ||
|
@@ -1240,6 +1269,7 @@ private SearchSourceBuilder shallowCopy( | |
rewrittenBuilder.derivedFieldsObject = derivedFieldsObject; | ||
rewrittenBuilder.derivedFields = derivedFields; | ||
rewrittenBuilder.searchPipeline = searchPipeline; | ||
rewrittenBuilder.verbosePipeline = verbosePipeline; | ||
return rewrittenBuilder; | ||
} | ||
|
||
|
@@ -1309,6 +1339,8 @@ public void parseXContent(XContentParser parser, boolean checkTrailingTokens) th | |
profile = parser.booleanValue(); | ||
} else if (SEARCH_PIPELINE.match(currentFieldName, parser.getDeprecationHandler())) { | ||
searchPipeline = parser.text(); | ||
} else if (VERBOSE_SEARCH_PIPELINE.match(currentFieldName, parser.getDeprecationHandler())) { | ||
verbosePipeline = parser.booleanValue(); | ||
} else { | ||
throw new ParsingException( | ||
parser.getTokenLocation(), | ||
|
@@ -1920,7 +1952,8 @@ public int hashCode() { | |
pointInTimeBuilder, | ||
derivedFieldsObject, | ||
derivedFields, | ||
searchPipeline | ||
searchPipeline, | ||
verbosePipeline | ||
); | ||
} | ||
|
||
|
@@ -1966,7 +1999,8 @@ public boolean equals(Object obj) { | |
&& Objects.equals(pointInTimeBuilder, other.pointInTimeBuilder) | ||
&& Objects.equals(derivedFieldsObject, other.derivedFieldsObject) | ||
&& Objects.equals(derivedFields, other.derivedFields) | ||
&& Objects.equals(searchPipeline, other.searchPipeline); | ||
&& Objects.equals(searchPipeline, other.searchPipeline) | ||
&& Objects.equals(verbosePipeline, other.verbosePipeline); | ||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
import org.opensearch.search.SearchExtBuilder; | ||
import org.opensearch.search.SearchHits; | ||
import org.opensearch.search.aggregations.InternalAggregations; | ||
import org.opensearch.search.pipeline.ProcessorExecutionDetail; | ||
import org.opensearch.search.profile.SearchProfileShardResults; | ||
import org.opensearch.search.suggest.Suggest; | ||
|
||
|
@@ -73,7 +74,17 @@ public InternalSearchResponse( | |
Boolean terminatedEarly, | ||
int numReducePhases | ||
) { | ||
this(hits, aggregations, suggest, profileResults, timedOut, terminatedEarly, numReducePhases, Collections.emptyList()); | ||
this( | ||
hits, | ||
aggregations, | ||
suggest, | ||
profileResults, | ||
timedOut, | ||
terminatedEarly, | ||
numReducePhases, | ||
Collections.emptyList(), | ||
Collections.emptyList() | ||
); | ||
} | ||
|
||
public InternalSearchResponse( | ||
|
@@ -84,9 +95,20 @@ public InternalSearchResponse( | |
boolean timedOut, | ||
Boolean terminatedEarly, | ||
int numReducePhases, | ||
List<SearchExtBuilder> searchExtBuilderList | ||
List<SearchExtBuilder> searchExtBuilderList, | ||
List<ProcessorExecutionDetail> processorResult | ||
) { | ||
super(hits, aggregations, suggest, timedOut, terminatedEarly, profileResults, numReducePhases, searchExtBuilderList); | ||
super( | ||
hits, | ||
aggregations, | ||
suggest, | ||
timedOut, | ||
terminatedEarly, | ||
profileResults, | ||
numReducePhases, | ||
searchExtBuilderList, | ||
processorResult | ||
); | ||
} | ||
|
||
public InternalSearchResponse(StreamInput in) throws IOException { | ||
|
@@ -98,7 +120,8 @@ public InternalSearchResponse(StreamInput in) throws IOException { | |
in.readOptionalBoolean(), | ||
in.readOptionalWriteable(SearchProfileShardResults::new), | ||
in.readVInt(), | ||
readSearchExtBuildersOnOrAfter(in) | ||
readSearchExtBuildersOnOrAfter(in), | ||
readProcessorResultOnOrAfter(in) | ||
); | ||
} | ||
|
||
|
@@ -112,6 +135,7 @@ public void writeTo(StreamOutput out) throws IOException { | |
out.writeOptionalWriteable(profileResults); | ||
out.writeVInt(numReducePhases); | ||
writeSearchExtBuildersOnOrAfter(out, searchExtBuilders); | ||
writeProcessorResultOnOrAfter(out, processorResult); | ||
} | ||
|
||
private static List<SearchExtBuilder> readSearchExtBuildersOnOrAfter(StreamInput in) throws IOException { | ||
|
@@ -123,4 +147,15 @@ private static void writeSearchExtBuildersOnOrAfter(StreamOutput out, List<Searc | |
out.writeNamedWriteableList(searchExtBuilders); | ||
} | ||
} | ||
|
||
private static List<ProcessorExecutionDetail> readProcessorResultOnOrAfter(StreamInput in) throws IOException { | ||
return (in.getVersion().onOrAfter(Version.V_2_18_0)) ? in.readList(ProcessorExecutionDetail::new) : Collections.emptyList(); | ||
} | ||
|
||
private static void writeProcessorResultOnOrAfter(StreamOutput out, List<ProcessorExecutionDetail> processorResult) throws IOException { | ||
if (out.getVersion().onOrAfter(Version.V_2_18_0)) { | ||
out.writeCollection(processorResult, (o, detail) -> detail.writeTo(o)); | ||
junweid62 marked this conversation as resolved.
Show resolved
Hide resolved
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. +1 to Josh's comment, please use |
||
} | ||
} | ||
|
||
} |
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.
link has to point to PR #16843, current one is for the issue