Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdelest committed Nov 29, 2024
1 parent 0dab8ea commit 257b75d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class RescoreVectorBuilder implements Writeable, ToXContentObject {

public static final ParseField OVERSAMPLE_FIELD = new ParseField("oversample");
public static final int MIN_OVERSAMPLE = 1;
public static final float MIN_OVERSAMPLE = 1.0F;
private static final ConstructingObjectParser<RescoreVectorBuilder, Void> PARSER = new ConstructingObjectParser<>(
"rescore",
args -> new RescoreVectorBuilder((Float) args[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ public void testInvalidK() {
assertThat(e.getMessage(), containsString("[k] must be greater than 0"));
}

public void testInvalidRescoreVectorBuilder() {
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
() -> new KnnSearchBuilder("field", randomVector(3), 0, 100, new RescoreVectorBuilder(1.0F), null)
);
assertThat(e.getMessage(), containsString("[oversample] must be > 1.0"));
}

public void testRewrite() throws Exception {
float[] expectedArray = randomVector(randomIntBetween(10, 1024));
RescoreVectorBuilder expectedRescore = new RescoreVectorBuilder(randomFloatBetween(1.0f, 10.0f, false));
Expand Down

0 comments on commit 257b75d

Please sign in to comment.