Skip to content

Commit ddc6094

Browse files
committed
Make rescore parameter mandatory
1 parent 69b5451 commit ddc6094

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

server/src/main/java/org/elasticsearch/search/vectors/RescoreVectorBuilder.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ public class RescoreVectorBuilder implements Writeable, ToXContentObject {
3131
);
3232

3333
static {
34-
PARSER.declareFloat(ConstructingObjectParser.optionalConstructorArg(), OVERSAMPLE_FIELD);
34+
PARSER.declareFloat(ConstructingObjectParser.constructorArg(), OVERSAMPLE_FIELD);
3535
}
3636

3737
// Oversample is required as of now as it is the only field in the rescore vector
38-
// that may change in the future, so we treat it as optional
39-
private final Float oversample;
38+
private final float oversample;
4039

4140
public RescoreVectorBuilder(Float oversample) {
4241
Objects.requireNonNull(oversample, "[" + OVERSAMPLE_FIELD.getPreferredName() + "] must be set");
@@ -47,20 +46,19 @@ public RescoreVectorBuilder(Float oversample) {
4746
}
4847

4948
public RescoreVectorBuilder(StreamInput in) throws IOException {
50-
this.oversample = in.readOptionalFloat();
49+
this.oversample = in.readFloat();
5150
}
5251

5352
@Override
5453
public void writeTo(StreamOutput out) throws IOException {
55-
out.writeOptionalFloat(oversample);
54+
out.writeFloat(oversample);
5655
}
5756

5857
@Override
5958
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
60-
if (oversample != null) {
61-
builder.field(OVERSAMPLE_FIELD.getPreferredName(), oversample);
62-
}
63-
59+
builder.startObject();
60+
builder.field(OVERSAMPLE_FIELD.getPreferredName(), oversample);
61+
builder.endObject();
6462
return builder;
6563
}
6664

0 commit comments

Comments
 (0)