elasticsearch-java icon indicating copy to clipboard operation
elasticsearch-java copied to clipboard

Create Index Mapping: The dims parameter for dense vector field type should be optional

Open spinscale opened this issue 1 year ago • 0 comments

Java API client version

8.11.1

Java version

21

Elasticsearch Version

8.11.1

Problem description

The following snippet returns an error, but should not according to the documentation

        client.indices().create(b -> b
                .index("wikipedia-german")
                .mappings(mb -> mb
                        .properties("paragraphs", pb -> pb.nested(nb -> nb
                                .properties("vector", vb -> vb.denseVector(t -> t))
                                .properties("text", tb -> tb.text(t -> t.index(false))))
                        )
                )
        );

results in

Exception in thread "main" co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'DenseVectorProperty.dims'

However, the documentation for 8.11 states at https://www.elastic.co/guide/en/elasticsearch/reference/current/dense-vector.html#dense-vector-params:

 dims
    (Optional, integer) Number of vector dimensions. Can’t exceed 4096. If dims is not specified, it will be set to the length of the first vector added to the field. 

spinscale avatar Nov 29 '23 11:11 spinscale