Skip to content

Commit

Permalink
Updates version to fix BWC for SearchSourceBuilder (opensearch-projec…
Browse files Browse the repository at this point in the history
…t#17098)

* change version to 2.19

Signed-off-by: Junwei Dai <[email protected]>

* bring back the constructor InternalSearchResponse and SearchResponseSections

Signed-off-by: Junwei Dai <[email protected]>

---------

Signed-off-by: Junwei Dai <[email protected]>
Co-authored-by: Junwei Dai <[email protected]>
  • Loading branch information
junweid62 and Junwei Dai authored Jan 23, 2025
1 parent c6dfc65 commit 94dfe6d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,29 @@ public SearchResponseSections(
this.searchExtBuilders.addAll(Objects.requireNonNull(searchExtBuilders, "searchExtBuilders must not be null"));
}

public SearchResponseSections(
SearchHits hits,
Aggregations aggregations,
Suggest suggest,
boolean timedOut,
Boolean terminatedEarly,
SearchProfileShardResults profileResults,
int numReducePhases,
List<SearchExtBuilder> searchExtBuilders
) {
this(
hits,
aggregations,
suggest,
timedOut,
terminatedEarly,
profileResults,
numReducePhases,
searchExtBuilders,
Collections.emptyList()
);
}

public final boolean timedOut() {
return this.timedOut;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public SearchSourceBuilder(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_2_18_0)) {
searchPipeline = in.readOptionalString();
}
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
if (in.getVersion().onOrAfter(Version.V_2_19_0)) {
verbosePipeline = in.readBoolean();
}
}
Expand Down Expand Up @@ -391,7 +391,7 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_2_18_0)) {
out.writeOptionalString(searchPipeline);
}
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_19_0)) {
out.writeBoolean(verbosePipeline);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ public InternalSearchResponse(
);
}

public InternalSearchResponse(
SearchHits hits,
InternalAggregations aggregations,
Suggest suggest,
SearchProfileShardResults profileResults,
boolean timedOut,
Boolean terminatedEarly,
int numReducePhases,
List<SearchExtBuilder> searchExtBuilderList

) {
super(
hits,
aggregations,
suggest,
timedOut,
terminatedEarly,
profileResults,
numReducePhases,
searchExtBuilderList,
Collections.emptyList()
);
}

public InternalSearchResponse(StreamInput in) throws IOException {
super(
new SearchHits(in),
Expand Down Expand Up @@ -149,11 +173,11 @@ private static void writeSearchExtBuildersOnOrAfter(StreamOutput out, List<Searc
}

private static List<ProcessorExecutionDetail> readProcessorResultOnOrAfter(StreamInput in) throws IOException {
return (in.getVersion().onOrAfter(Version.V_3_0_0)) ? in.readList(ProcessorExecutionDetail::new) : Collections.emptyList();
return (in.getVersion().onOrAfter(Version.V_2_19_0)) ? in.readList(ProcessorExecutionDetail::new) : Collections.emptyList();
}

private static void writeProcessorResultOnOrAfter(StreamOutput out, List<ProcessorExecutionDetail> processorResult) throws IOException {
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_19_0)) {
out.writeList(processorResult);
}
}
Expand Down

0 comments on commit 94dfe6d

Please sign in to comment.