Skip to content

Commit

Permalink
Add builder constructor that takes algo params (opendistro-for-elasti…
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazanec15 committed Dec 30, 2020
1 parent de2019a commit 721108c
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,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 @@ -119,10 +130,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 @@ -337,7 +359,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

0 comments on commit 721108c

Please sign in to comment.