From 42e50d0727e09b8e85a5eaa73262f0e2ec339da1 Mon Sep 17 00:00:00 2001 From: Junwei Dai Date: Tue, 21 Jan 2025 16:27:38 -0800 Subject: [PATCH] fix unit test Signed-off-by: Junwei Dai --- .../opensearch/search/builder/SearchSourceBuilder.java | 10 +++++----- .../search/builder/SearchSourceBuilderTests.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java index e59baa7b925da..fb21eaff5f857 100644 --- a/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java @@ -227,7 +227,7 @@ public static HighlightBuilder highlight() { private String searchPipeline; - private Boolean verbosePipeline; + private boolean verbosePipeline = false; /** * Constructs a new search source builder. @@ -306,7 +306,7 @@ public SearchSourceBuilder(StreamInput in) throws IOException { searchPipeline = in.readOptionalString(); } if (in.getVersion().onOrAfter(Version.V_3_0_0)) { - verbosePipeline = in.readOptionalBoolean(); + verbosePipeline = in.readBoolean(); } } @@ -392,7 +392,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(searchPipeline); } if (out.getVersion().onOrAfter(Version.V_3_0_0)) { - out.writeOptionalBoolean(verbosePipeline); + out.writeBoolean(verbosePipeline); } } @@ -1162,7 +1162,7 @@ public SearchSourceBuilder pipeline(String searchPipeline) { * to track how data flows and transforms through the search pipeline. * */ - public SearchSourceBuilder verbosePipeline(boolean verbosePipeline) { + public SearchSourceBuilder verbosePipeline(Boolean verbosePipeline) { this.verbosePipeline = verbosePipeline; return this; } @@ -1674,7 +1674,7 @@ public XContentBuilder innerToXContent(XContentBuilder builder, Params params) t builder.field(SEARCH_PIPELINE.getPreferredName(), searchPipeline); } - if (verbosePipeline != null) { + if (verbosePipeline) { builder.field(VERBOSE_SEARCH_PIPELINE.getPreferredName(), verbosePipeline); } diff --git a/server/src/test/java/org/opensearch/search/builder/SearchSourceBuilderTests.java b/server/src/test/java/org/opensearch/search/builder/SearchSourceBuilderTests.java index 64d1e22c31871..90962a5c613f1 100644 --- a/server/src/test/java/org/opensearch/search/builder/SearchSourceBuilderTests.java +++ b/server/src/test/java/org/opensearch/search/builder/SearchSourceBuilderTests.java @@ -722,7 +722,7 @@ public void testVerbosePipeline() throws IOException { String restContent = "{ \"query\": { \"match_all\": {} } }"; try (XContentParser parser = createParser(JsonXContent.jsonXContent, restContent)) { SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.fromXContent(parser); - assertNull(searchSourceBuilder.verbosePipeline()); + assertFalse(searchSourceBuilder.verbosePipeline()); } } }