Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add builder constructor that takes algo params #289

Merged
Merged
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 @@ -101,10 +101,21 @@ public static class Builder extends ParametrizedFieldMapper.Builder {
}, m -> toType(m).dimension);
private final Parameter<Map<String, String>> meta = Parameter.metaParam();

private String spaceType;
private String m;
private String efConstruction;

public Builder(String name) {
super(name);
}

public Builder(String name, String spaceType, String m, String efConstruction) {
super(name);
this.spaceType = spaceType;
this.m = m;
this.efConstruction = efConstruction;
}

@Override
protected List<Parameter<?>> getParameters() {
return Arrays.asList(stored, hasDocValues, dimension, meta);
Expand All @@ -122,10 +133,21 @@ protected Explicit<Boolean> ignoreMalformed(BuilderContext context) {

@Override
public KNNVectorFieldMapper build(BuilderContext context) {
if (this.spaceType == null) {
this.spaceType = getSpaceType(context.indexSettings());
}

if (this.m == null) {
this.m = getM(context.indexSettings());
}

if (this.efConstruction == null) {
this.efConstruction = getEfConstruction(context.indexSettings());
}

return new KNNVectorFieldMapper(name, new KNNVectorFieldType(buildFullName(context), meta.getValue(),
dimension.getValue()), multiFieldsBuilder.build(this, context),
ignoreMalformed(context), getSpaceType(context.indexSettings()), getM(context.indexSettings()),
getEfConstruction(context.indexSettings()), copyTo.build(), this);
ignoreMalformed(context), this.spaceType, this.m, this.efConstruction, copyTo.build(), this);
}

private String getSpaceType(Settings indexSettings) {
Expand Down Expand Up @@ -346,7 +368,7 @@ protected boolean docValuesByDefault() {

@Override
public ParametrizedFieldMapper.Builder getMergeBuilder() {
return new KNNVectorFieldMapper.Builder(simpleName()).init(this);
return new KNNVectorFieldMapper.Builder(simpleName(), this.spaceType, this.m, this.efConstruction).init(this);
}

@Override
Expand Down