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

**URL:** <https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [August 4, 2022, 10:50pm UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464 "2022-08-04T22:50:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![notricky](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@notricky](https://discuss.elastic.co/u/notricky)\
**Post date:** [August 4, 2022, 10:50pm UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464/1 "2022-08-04T22:50:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 4, 2022, 11:11pm UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464/2 "2022-08-04T23:11:00Z")

</div>

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:

> **[MissingRequiredPropertyException in a response | Elasticsearch Java API...](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/missing-required-property.html)**

---

<div class="post-metadata">

**Author:** ![notricky](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@notricky](https://discuss.elastic.co/u/notricky)\
**Post date:** [August 5, 2022, 9:47am UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464/3 "2022-08-05T09:47:14Z")

</div>

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

```auto
 new CreateIndexRequest.Builder().
        .settings(s -> s
                .similarity(
                    new SettingsSimilarity.Builder().lmj(
                        new SettingsSimilarityLmj.Builder()
                            .lambda(2)
                            .build()
                    ).build()
                )
    )

```

runs into error:

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

```

Will try now to use the sencod approach you suggested.

---

<div class="post-metadata">

**Author:** ![notricky](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@notricky](https://discuss.elastic.co/u/notricky)\
**Post date:** [August 5, 2022, 10:42am UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464/4 "2022-08-05T10:42:19Z")

</div>

Well, seems that second approach doenst help much, even by setting  
` ApiTypeHelper.DANGEROUS_disableRequiredPropertiesCheck(true);`

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 5, 2022, 11:21am UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464/5 "2022-08-05T11:21:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![notricky](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@notricky](https://discuss.elastic.co/u/notricky)\
**Post date:** [August 5, 2022, 10:23pm UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464/6 "2022-08-05T22:23:17Z")

</div>

Well I guess its a last hope. An issue is here: [elasticsearch-java/issues/366](https://github.com/elastic/elasticsearch-java/issues/366)

---

<div class="post-metadata">

**Author:** ![notricky](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@notricky](https://discuss.elastic.co/u/notricky)\
**Post date:** [August 16, 2022, 11:42pm UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464/7 "2022-08-16T23:42:30Z")

</div>

Well, no answers or replies anywhere...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 13, 2022, 11:43pm UTC](https://discuss.elastic.co/t/java-api-client-8-x-settingssimilarity-doesnt-have-field-type-for-correct-request-completion/311464/8 "2022-09-13T23:43:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
