Skip to content

Commit

Permalink
Update knn query parameter expand_nested_docs tp expand_nested and up…
Browse files Browse the repository at this point in the history
…date the change log.

Signed-off-by: Bo Zhang <bzhangam@amazon.com>
  • Loading branch information
bzhangam committed Dec 16, 2024
1 parent c515587 commit 07ddbc0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Features
### Enhancements
- Set neural-search plugin 3.0.0 baseline JDK version to JDK-2 ([#838](https://github.com/opensearch-project/neural-search/pull/838))
- Support new knn query parameter expand_nested_docs ([#1008](https://github.com/opensearch-project/neural-search/issues/1008))
### Bug Fixes
- Fix for nested field missing sub embedding field in text embedding processor ([#913](https://github.com/opensearch-project/neural-search/pull/913))
### Infrastructure
Expand All @@ -18,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased 2.x](https://github.com/opensearch-project/neural-search/compare/2.18...2.x)
### Features
### Enhancements
- Support new knn query parameter expand_nested_docs ([#1013](https://github.com/opensearch-project/neural-search/pull/1013))
### Bug Fixes
- Address inconsistent scoring in hybrid query results ([#998](https://github.com/opensearch-project/neural-search/pull/998))
### Infrastructure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private HybridQueryBuilder getQueryBuilder(
neuralQueryBuilder.queryText(QUERY);
neuralQueryBuilder.k(5);
if (expandNestedDocs != null) {
neuralQueryBuilder.expandNestedDocs(expandNestedDocs);
neuralQueryBuilder.expandNested(expandNestedDocs);
}
if (methodParameters != null) {
neuralQueryBuilder.methodParameters(methodParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private HybridQueryBuilder getQueryBuilder(
neuralQueryBuilder.queryText(QUERY);
neuralQueryBuilder.k(5);
if (expandNestedDocs != null) {
neuralQueryBuilder.expandNestedDocs(expandNestedDocs);
neuralQueryBuilder.expandNested(expandNestedDocs);
}
if (methodParameters != null) {
neuralQueryBuilder.methodParameters(methodParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void initialize(MLCommonsClientAccessor mlClient) {
private Integer k = null;
private Float maxDistance = null;
private Float minScore = null;
private Boolean expandNestedDocs;
private Boolean expandNested;
@VisibleForTesting
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
Expand Down Expand Up @@ -135,7 +135,7 @@ public NeuralQueryBuilder(StreamInput in) throws IOException {
this.minScore = in.readOptionalFloat();
}
if (isClusterOnOrAfterMinReqVersion(EXPAND_NESTED_FIELD.getPreferredName())) {
this.expandNestedDocs = in.readOptionalBoolean();
this.expandNested = in.readOptionalBoolean();
}
if (isClusterOnOrAfterMinReqVersion(METHOD_PARAMS_FIELD.getPreferredName())) {
this.methodParameters = MethodParametersParser.streamInput(in, MinClusterVersionUtil::isClusterOnOrAfterMinReqVersion);
Expand Down Expand Up @@ -164,7 +164,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeOptionalFloat(this.minScore);
}
if (isClusterOnOrAfterMinReqVersion(EXPAND_NESTED_FIELD.getPreferredName())) {
out.writeOptionalBoolean(this.expandNestedDocs);
out.writeOptionalBoolean(this.expandNested);
}
if (isClusterOnOrAfterMinReqVersion(METHOD_PARAMS_FIELD.getPreferredName())) {
MethodParametersParser.streamOutput(out, methodParameters, MinClusterVersionUtil::isClusterOnOrAfterMinReqVersion);
Expand Down Expand Up @@ -192,8 +192,8 @@ protected void doXContent(XContentBuilder xContentBuilder, Params params) throws
if (Objects.nonNull(minScore)) {
xContentBuilder.field(MIN_SCORE_FIELD.getPreferredName(), minScore);
}
if (Objects.nonNull(expandNestedDocs)) {
xContentBuilder.field(EXPAND_NESTED_FIELD.getPreferredName(), expandNestedDocs);
if (Objects.nonNull(expandNested)) {
xContentBuilder.field(EXPAND_NESTED_FIELD.getPreferredName(), expandNested);
}
if (Objects.nonNull(methodParameters)) {
MethodParametersParser.doXContent(xContentBuilder, methodParameters);
Expand Down Expand Up @@ -286,7 +286,7 @@ private static void parseQueryParams(XContentParser parser, NeuralQueryBuilder n
} else if (MIN_SCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
neuralQueryBuilder.minScore(parser.floatValue());
} else if (EXPAND_NESTED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
neuralQueryBuilder.expandNestedDocs(parser.booleanValue());
neuralQueryBuilder.expandNested(parser.booleanValue());
} else {
throw new ParsingException(
parser.getTokenLocation(),
Expand Down Expand Up @@ -331,7 +331,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) {
.filter(filter())
.maxDistance(maxDistance)
.minScore(minScore)
.expandNested(expandNestedDocs)
.expandNested(expandNested)
.k(k)
.methodParameters(methodParameters)
.rescoreContext(rescoreContext)
Expand Down Expand Up @@ -360,7 +360,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) {
k(),
maxDistance(),
minScore(),
expandNestedDocs(),
expandNested(),
vectorSetOnce::get,
filter(),
methodParameters(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void testFromXContent_whenBuiltWithOptionals_thenBuildSuccessfully() {
assertEquals(K, neuralQueryBuilder.k());
assertEquals(BOOST, neuralQueryBuilder.boost(), 0.0);
assertEquals(QUERY_NAME, neuralQueryBuilder.queryName());
assertEquals(Boolean.TRUE, neuralQueryBuilder.expandNestedDocs());
assertEquals(Boolean.TRUE, neuralQueryBuilder.expandNested());
}

@SneakyThrows
Expand Down Expand Up @@ -432,7 +432,7 @@ public void testToXContent() {
.modelId(MODEL_ID)
.queryText(QUERY_TEXT)
.k(K)
.expandNestedDocs(Boolean.TRUE)
.expandNested(Boolean.TRUE)
.filter(TEST_FILTER);

XContentBuilder builder = XContentFactory.jsonBuilder();
Expand Down Expand Up @@ -724,7 +724,7 @@ public void testRewrite_whenVectorNull_thenReturnCopy() {
.queryImage(IMAGE_TEXT)
.modelId(MODEL_ID)
.k(K)
.expandNestedDocs(Boolean.TRUE)
.expandNested(Boolean.TRUE)
.vectorSupplier(nullSupplier);
QueryBuilder queryBuilder = neuralQueryBuilder.doRewrite(null);
assertEquals(neuralQueryBuilder, queryBuilder);
Expand All @@ -736,7 +736,7 @@ public void testRewrite_whenVectorSupplierAndVectorSet_thenReturnKNNQueryBuilder
.queryImage(IMAGE_TEXT)
.modelId(MODEL_ID)
.k(K)
.expandNestedDocs(Boolean.TRUE)
.expandNested(Boolean.TRUE)
.methodParameters(Map.of("ef_search", 100))
.rescoreContext(RescoreContext.getDefault())
.vectorSupplier(TEST_VECTOR_SUPPLIER);
Expand Down

0 comments on commit 07ddbc0

Please sign in to comment.