# Java Client API migration: FieldValue does not accept an Object value

**URL:** <https://discuss.elastic.co/t/java-client-api-migration-fieldvalue-does-not-accept-an-object-value/300069>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [March 18, 2022, 4:28pm UTC](https://discuss.elastic.co/t/java-client-api-migration-fieldvalue-does-not-accept-an-object-value/300069 "2022-03-18T16:28:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbrunot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sbrunot/32/103222_2.png) [@sbrunot](https://discuss.elastic.co/u/sbrunot)\
**Post date:** [March 18, 2022, 4:28pm UTC](https://discuss.elastic.co/t/java-client-api-migration-fieldvalue-does-not-accept-an-object-value/300069/1 "2022-03-18T16:28:59Z")

</div>

Hi,

the deprecated Java High Level REST Client API allowed to specify a Term query by providing the value as an Object (see [QueryBuilders (server 7.8.1 API)](https://artifacts.elastic.co/javadoc/org/elasticsearch/elasticsearch/7.8.1/org/elasticsearch/index/query/QueryBuilders.html#termQuery(java.lang.String,java.lang.Object))

With the new Java Client API, it doesn't seem to be possible anymore, as there are way to provide an Object value to FieldValue.Builder

Are there any plan to add this previous capability to the new API ?

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [March 22, 2022, 2:21pm UTC](https://discuss.elastic.co/t/java-client-api-migration-fieldvalue-does-not-accept-an-object-value/300069/2 "2022-03-22T14:21:56Z")

</div>

We want to avoid untyped `Object` as much as possible in the Java API client. Can you provide additional details on your use case? What is the actual type of the value you want to use?

---

<div class="post-metadata">

**Author:** ![sbrunot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sbrunot/32/103222_2.png) [@sbrunot](https://discuss.elastic.co/u/sbrunot)\
**Post date:** [March 22, 2022, 4:30pm UTC](https://discuss.elastic.co/t/java-client-api-migration-fieldvalue-does-not-accept-an-object-value/300069/3 "2022-03-22T16:30:43Z")

</div>

My first goal is to be able to migrate our existing code as easily as possible, I wasn't expected features to be removed from the new API.

An example of types of values that I would like to use are related to date: Calendar / GregorianCalendar , Date, ...

The huge regression here is that the Elasticsearch API used to transform java types into their appropriate JSON representation for Elasticsearch by itself, and that we now have to handle that ourselves...

---

<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:** [April 19, 2022, 4:31pm UTC](https://discuss.elastic.co/t/java-client-api-migration-fieldvalue-does-not-accept-an-object-value/300069/4 "2022-04-19T16:31:06Z")

</div>

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