Skip to content

Commit

Permalink
Fixing Build
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Jain <[email protected]>
  • Loading branch information
vibrantvarun committed Jul 4, 2024
1 parent 91732de commit 9535ee9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,14 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) {
if (vectorSupplier().get() == null) {
return this;
}
KNNQueryBuilder knnQueryBuilder = new KNNQueryBuilder(fieldName(), vectorSupplier.get()).filter(filter());
if (maxDistance != null) {
knnQueryBuilder.maxDistance(maxDistance);
} else if (minScore != null) {
knnQueryBuilder.minScore(minScore);
} else {
knnQueryBuilder.k(k);
}
return knnQueryBuilder;
return KNNQueryBuilder.builder()
.fieldName(fieldName())
.vector(vectorSupplier.get())
.filter(filter())
.maxDistance(maxDistance)
.minScore(minScore)
.k(k)
.build();
}

SetOnce<float[]> vectorSetOnce = new SetOnce<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ private static void validateMapTypeValue(
allowEmpty
);
} else if (!(nextSourceValue instanceof String)) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "map type field [%s] is neither string nor nested type, cannot process it", key));
throw new IllegalArgumentException(
String.format(Locale.ROOT, "map type field [%s] is neither string nor nested type, cannot process it", key)
);
} else if (!allowEmpty && StringUtils.isBlank((String) nextSourceValue)) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "map type field [%s] has empty string value, cannot process it", key));
throw new IllegalArgumentException(
String.format(Locale.ROOT, "map type field [%s] has empty string value, cannot process it", key)
);
}
}
});
Expand All @@ -126,10 +130,14 @@ private static void validateListTypeValue(
}
for (Object element : sourceValue) {
if (Objects.isNull(element)) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "list type field [%s] has null, cannot process it", sourceKey));
throw new IllegalArgumentException(
String.format(Locale.ROOT, "list type field [%s] has null, cannot process it", sourceKey)
);
}
if (element instanceof List) { // nested list case.
throw new IllegalArgumentException(String.format(Locale.ROOT, "list type field [%s] is nested list type, cannot process it", sourceKey));
throw new IllegalArgumentException(
String.format(Locale.ROOT, "list type field [%s] is nested list type, cannot process it", sourceKey)
);
} else if (element instanceof Map) {
validateMapTypeValue(
sourceKey,
Expand All @@ -142,9 +150,13 @@ private static void validateListTypeValue(
allowEmpty
);
} else if (!(element instanceof String)) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "list type field [%s] has non string value, cannot process it", sourceKey));
throw new IllegalArgumentException(
String.format(Locale.ROOT, "list type field [%s] has non string value, cannot process it", sourceKey)
);
} else if (!allowEmpty && StringUtils.isBlank(element.toString())) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "list type field [%s] has empty string, cannot process it", sourceKey));
throw new IllegalArgumentException(
String.format(Locale.ROOT, "list type field [%s] has empty string, cannot process it", sourceKey)
);
}
}
}
Expand All @@ -161,7 +173,9 @@ private static void validateDepth(
.orElse(environment.settings());
long maxDepth = MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING.get(settings);
if (depth > maxDepth) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "map type field [%s] reaches max depth limit, cannot process it", sourceKey));
throw new IllegalArgumentException(
String.format(Locale.ROOT, "map type field [%s] reaches max depth limit, cannot process it", sourceKey)
);
}
}
}

0 comments on commit 9535ee9

Please sign in to comment.