Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: nested neural_sparse search throws error if model_id not supplied and default_model_id is configured #872

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,24 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
}

private static void validateForRewrite(String queryText, String modelId) {
if (StringUtils.isBlank(queryText) || StringUtils.isBlank(modelId)) {
if (StringUtils.isBlank(modelId) && !isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isClusterOnOrAfterMinReqVersionForDefaultModelIdSupport only checks whether the default model id feature is supported in the current cluster by OpenSearch version. Have you checked that default model id has been configured?

throw new IllegalArgumentException(
String.format(
Locale.ROOT,
"%s and %s cannot be null",
QUERY_TEXT_FIELD.getPreferredName(),
"%s cannot be null",
MODEL_ID_FIELD.getPreferredName()
)
);
}
if (StringUtils.isBlank(queryText)) {
throw new IllegalArgumentException(
String.format(
Locale.ROOT,
"%s cannot be null",
QUERY_TEXT_FIELD.getPreferredName()
)
);
}
}

private static void validateFieldType(MappedFieldType fieldType) {
Expand Down
Loading