Skip to content

Commit

Permalink
make m,ef_construction,dimensions static in os index create
Browse files Browse the repository at this point in the history
  • Loading branch information
jshook committed Feb 15, 2024
1 parent 4ad42f8 commit 33389ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 114 deletions.
Expand Up @@ -30,8 +30,17 @@

public class CreateIndexOpDispenser extends BaseOpenSearchOpDispenser {

private final ParsedOp pop;
private final int dimensions;
private final int ef_construction;
private final int m;

public CreateIndexOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
super(adapter, op, targetF);
this.pop = op;
this.dimensions = pop.getStaticValue("dimensions",Integer.class).intValue();
this.ef_construction = pop.getStaticValue("ef_construction",Integer.class).intValue();
this.m = pop.getStaticValue("m",Integer.class).intValue();
}

@Override
Expand All @@ -50,6 +59,7 @@ public LongFunction<CreateIndexOp> createOpFunc(LongFunction<OpenSearchClient> c

// https://opensearch.org/docs/latest/search-plugins/knn/knn-index/
private CreateIndexRequest.Builder resolveTypeMapping(CreateIndexRequest.Builder eb, Map<?, ?> mappings) {

TypeMapping.Builder builder = new TypeMapping.Builder().properties(
Map.of(
"key",
Expand All @@ -59,13 +69,18 @@ private CreateIndexRequest.Builder resolveTypeMapping(CreateIndexRequest.Builder
"value",
new Property.Builder()
.knnVector(new KnnVectorProperty.Builder()
.dimension(25)
.dimension(dimensions)
.method(
new KnnVectorMethod.Builder()
.name("hnsw")
.engine("faiss")
.spaceType("l2")
.parameters(Map.of("ef_construction", JsonData.of(256), "m", JsonData.of(8)))
.parameters(
Map.of(
"ef_construction", JsonData.of(ef_construction),
"m", JsonData.of(m)
)
)
.build()
).build()
).build()
Expand Down
112 changes: 0 additions & 112 deletions adapter-aws-opensearch/src/main/resources/activities/osvectors.yaml

This file was deleted.

0 comments on commit 33389ea

Please sign in to comment.