Skip to content

optional options for dense vectors are not optional when using the Java client #846

Closed
@dadoonet

Description

@dadoonet

Elasticsearch Version

8.14.3

Installed Plugins

No response

Java Version

bundled

OS Version

cloud

Problem Description

The documentation for dense vectors specifies some optional index options. Which means that I can create an index like this:

DELETE test 
PUT test 
{
  "mappings": {
    "properties": {
      "vector": {
        "type": "dense_vector",
        "index_options": {
          "type": "hnsw"
        }
      }
    }
  }
}

But in Java, I must specify a value for m and efConstruction:

client.indices().create(c -> c.index("test")
        .mappings(m -> m
                .properties("vector", p -> p.denseVector(dv -> dv
                        .indexOptions(dvio -> dvio
                                .type("hnsw")
                        )
                ))
        ));

This fails as it's missing values. So I have to fix the code with:

client.indices().create(c -> c.index("test")
        .mappings(m -> m
                .properties("vector", p -> p.denseVector(dv -> dv
                        .indexOptions(dvio -> dvio
                                .m(16)
                                .efConstruction(100)
                                .type("hnsw")
                        )
                ))
        ));

Steps to Reproduce

Run this code:

client.indices().create(c -> c.index("test")
        .mappings(m -> m
                .properties("vector", p -> p.denseVector(dv -> dv
                        .indexOptions(dvio -> dvio
                                .type("hnsw")
                        )
                ))
        ));

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: SpecificationRelated to the API spec used to generate client codeCategory: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions