Skip to content

Commit

Permalink
Comments Addressed of Jack
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Jain <[email protected]>
  • Loading branch information
vibrantvarun committed Sep 28, 2023
1 parent c9ada83 commit 4be198c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public NeuralQueryProcessor create(
boolean ignoreFailure,
Map<String, Object> config,
PipelineContext pipelineContext
) throws Exception {
) throws IllegalArgumentException {
String modelId = (String) config.remove(DEFAULT_MODEL_ID);
Map<String, Object> neuralInfoMap = ConfigurationUtils.readOptionalMap(TYPE, tag, config, NEURAL_FIELD_DEFAULT_ID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Check warning on line 102 in src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java#L102

Added line #L102 was not covered by tests
Expand All @@ -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);

Check warning on line 115 in src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java#L115

Added line #L115 was not covered by tests
Expand All @@ -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);
Expand Down Expand Up @@ -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");

Check warning on line 181 in src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java#L181

Added line #L181 was not covered by tests
}
return neuralQueryBuilder;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4be198c

Please sign in to comment.