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

Commit

Permalink
Fix bug in KNNVectorFieldMapper for ODFE 1.8 (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazanec15 authored Oct 14, 2020
1 parent 9d78114 commit 3a4e2fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public static class Defaults {
FIELD_TYPE.setHasDocValues(true);
FIELD_TYPE.setDocValuesType(DocValuesType.BINARY);
FIELD_TYPE.putAttribute(KNN_FIELD, "true"); //This attribute helps to determine knn field type
FIELD_TYPE.freeze();
}
}

Expand All @@ -105,12 +106,12 @@ public Builder ignoreMalformed(boolean ignoreMalformed) {
}

public Builder spaceTypeParam(String key, String paramValue) {
Defaults.FIELD_TYPE.putAttribute(key, paramValue.toLowerCase());
builder.fieldType.putAttribute(key, paramValue.toLowerCase());
return builder;
}

public Builder algoParams(String key, int paramValue) {
Defaults.FIELD_TYPE.putAttribute(key, String.valueOf(paramValue));
builder.fieldType.putAttribute(key, String.valueOf(paramValue));
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,13 @@ public void testBuildKNNIndexSettings_emptySettings_checkDefaultsSet() {
KNNVectorFieldMapper.TypeParser typeParser = new KNNVectorFieldMapper.TypeParser();
typeParser.buildKNNIndexSettings(builder, parserContext);

assertEquals(KNNVectorFieldMapper.Defaults.FIELD_TYPE.getAttributes().get(KNNConstants.SPACE_TYPE),
assertEquals(builder.fieldType().getAttributes().get(KNNConstants.SPACE_TYPE),
INDEX_KNN_DEFAULT_SPACE_TYPE);

assertEquals(KNNVectorFieldMapper.Defaults.FIELD_TYPE.getAttributes().get(KNNConstants.HNSW_ALGO_M),
assertEquals(builder.fieldType().getAttributes().get(KNNConstants.HNSW_ALGO_M),
String.valueOf(INDEX_KNN_DEFAULT_ALGO_PARAM_M));

assertEquals(KNNVectorFieldMapper.Defaults.FIELD_TYPE.getAttributes().get(
KNNConstants.HNSW_ALGO_EF_CONSTRUCTION), String.valueOf(
INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION));
assertEquals(builder.fieldType().getAttributes().get(KNNConstants.HNSW_ALGO_EF_CONSTRUCTION),
String.valueOf(INDEX_KNN_DEFAULT_ALGO_PARAM_EF_CONSTRUCTION));
}
}

0 comments on commit 3a4e2fc

Please sign in to comment.