Java API Client 8.x SettingsSimilarity doesnt have field 'type' for correct request completion

When you use 8.x Java Client to create an index within CreateIndexRequest.Builder and specify similarity in settings builder, there is no field type, which Elasticsearch server waits for and it returns an error, pointing that a type must be specified.

This behaviour begins from 8.0.1 version of client.

What is the best way using Java API to override this behaviour?

PS: Elasticsearch server ver 8.0.0

I'm not sure but first, I'd upgrade to the latest version of the client and the server.

Then, if the problem is still there, I'd try to use this:

Had upated today. Both client and server are of 8.3.3 ver. The code

 new CreateIndexRequest.Builder().
        .settings(s -> s
                    new SettingsSimilarity.Builder().lmj(
                        new SettingsSimilarityLmj.Builder()

runs into error:

[es/indices.create] failed: [illegal_argument_exception] Similarity [lmj] must have an associated type

Will try now to use the sencod approach you suggested.

Well, seems that second approach doenst help much, even by setting

The rest of it is to create a bug issue on github. But I'm a bit confused that nobody yet faced this common error.

Might be a bug indeed. May be open an issue?

Well I guess its a last hope. An issue is here: elasticsearch-java/issues/366