Skip to content

Commit

Permalink
add conditional for default model id support when validating model id…
Browse files Browse the repository at this point in the history
… presence
  • Loading branch information
jdnvn committed Aug 22, 2024
1 parent 03d528e commit 06eee4b
Showing 1 changed file with 11 additions and 3 deletions.
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()) {
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

0 comments on commit 06eee4b

Please sign in to comment.