diff --git a/src/main/java/org/opensearch/neuralsearch/processor/NeuralQueryProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/NeuralQueryProcessor.java index 8c52385e2..9c479b48e 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/NeuralQueryProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/NeuralQueryProcessor.java @@ -80,7 +80,7 @@ public NeuralQueryProcessor create( boolean ignoreFailure, Map config, PipelineContext pipelineContext - ) throws Exception { + ) throws IllegalArgumentException { String modelId = (String) config.remove(DEFAULT_MODEL_ID); Map neuralInfoMap = ConfigurationUtils.readOptionalMap(TYPE, tag, config, NEURAL_FIELD_DEFAULT_ID); diff --git a/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java b/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java index 728966428..6701b5835 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java @@ -96,7 +96,7 @@ public NeuralQueryBuilder(StreamInput in) throws IOException { super(in); this.fieldName = in.readString(); this.queryText = in.readString(); - if (isClusterOnOrAfterMinRequiredVersion()) { + if (isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport()) { this.modelId = in.readOptionalString(); } else { this.modelId = in.readString(); @@ -109,7 +109,7 @@ public NeuralQueryBuilder(StreamInput in) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(this.fieldName); out.writeString(this.queryText); - if (isClusterOnOrAfterMinRequiredVersion()) { + if (isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport()) { out.writeOptionalString(this.modelId); } else { out.writeString(this.modelId); @@ -123,7 +123,7 @@ protected void doXContent(XContentBuilder xContentBuilder, Params params) throws xContentBuilder.startObject(NAME); xContentBuilder.startObject(fieldName); xContentBuilder.field(QUERY_TEXT_FIELD.getPreferredName(), queryText); - if (!isClusterOnOrAfterMinRequiredVersion() || (isClusterOnOrAfterMinRequiredVersion() && modelId != null)) { + if (modelId != null) { xContentBuilder.field(MODEL_ID_FIELD.getPreferredName(), modelId); } xContentBuilder.field(K_FIELD.getPreferredName(), k); @@ -177,7 +177,7 @@ public static NeuralQueryBuilder fromXContent(XContentParser parser) throws IOEx } requireValue(neuralQueryBuilder.queryText(), "Query text must be provided for neural query"); requireValue(neuralQueryBuilder.fieldName(), "Field name must be provided for neural query"); - if (!isClusterOnOrAfterMinRequiredVersion()) { + if (!isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport()) { requireValue(neuralQueryBuilder.modelId(), "Model ID must be provided for neural query"); } return neuralQueryBuilder; @@ -273,7 +273,7 @@ public String getWriteableName() { return NAME; } - private static boolean isClusterOnOrAfterMinRequiredVersion() { + private static boolean isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport() { return NeuralSearchClusterUtil.instance().getClusterMinVersion().onOrAfter(MINIMAL_SUPPORTED_VERSION_DEFAULT_MODEL_ID); } } diff --git a/src/main/java/org/opensearch/neuralsearch/query/visitor/NeuralSearchQueryVisitor.java b/src/main/java/org/opensearch/neuralsearch/query/visitor/NeuralSearchQueryVisitor.java index 06148a5b5..9d746190c 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/visitor/NeuralSearchQueryVisitor.java +++ b/src/main/java/org/opensearch/neuralsearch/query/visitor/NeuralSearchQueryVisitor.java @@ -15,7 +15,7 @@ import org.opensearch.neuralsearch.query.NeuralQueryBuilder; /** - * Neural Search Query Visitor. It visits the each and every component of query buikder tree. + * Neural Search Query Visitor. It visits each and every component of query buikder tree. */ @AllArgsConstructor public class NeuralSearchQueryVisitor implements QueryBuilderVisitor {