# Java Client - Class Specification

**URL:** <https://forum.opensearch.org/t/java-client-class-specification/16161>\
**Category:** OpenSearch Client Libraries\
**Tags:** opensearch-java\
**Created:** [October 5, 2023, 1:43pm UTC](https://forum.opensearch.org/t/java-client-class-specification/16161 "2023-10-05T13:43:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![docme](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@docme](https://forum.opensearch.org/u/docme)\
**Post date:** [October 5, 2023, 1:43pm UTC](https://forum.opensearch.org/t/java-client-class-specification/16161/1 "2023-10-05T13:43:23Z")

</div>

The new Java Client requires a Java Class to specify the fields to be returned from a search request. I have reviewed the github pull request for Adding new generic client, #417 ([Adding new generic client by harshavamsi · Pull Request #415 · opensearch-project/opensearch-java · GitHub](https://github.com/opensearch-project/opensearch-java/pull/415)) and #377 ([[FEATURE] Enable Generic HTTP Actions in Java Client · Issue #377 · opensearch-project/opensearch-java · GitHub](https://github.com/opensearch-project/opensearch-java/issues/377)). Its not clear to me if this client will ultimately support specifying the return fields as currently provided by HLRC.

{ “size”: 1000, “query”: { “bool”: { “filter”: [{ “term”: { “module”: { “value”: “ncs”, “boost”: 1 } } }], “adjust\_pure\_negative”: true, “boost”: 1 } }, “\_source”: { “includes”: [“module”, “descp”, “\_id”], “excludes”: }, “sort”: [{ “module”: { “order”: “asc” } }] }

I would like to know if the new generic client will support json requests that specify \_source “includes” or “excludes” as an option to defining the return fields via a Java class, and if a generic client is planned before HLRC support is removed in the 4.0 release. This approach would remove the need to filter out unwanted class fields and reduce bandwidth costs over time as well.

---

<div class="post-metadata">

**Author:** ![docme](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@docme](https://forum.opensearch.org/u/docme)\
**Post date:** [November 6, 2023, 4:19pm UTC](https://forum.opensearch.org/t/java-client-class-specification/16161/2 "2023-11-06T16:19:15Z")

</div>

In #415 (Adding new generic client), a pull request by @harshavamia was marked as Draft on April 13th. The proposed sample was:

OpenSearchHttpClient httpClient = new OpenSearchHttpClient(transport); GetHttpRequest getHttpRequest = new GetHttpRequest.Builder().path(“/movies”).build();

try { JsonReader jsonReader = Json.createReader(new StringReader(httpClient.get(getHttpRequest))); JsonObject object = jsonReader.readObject(); System.out.println(object.toString()); } catch (OpenSearchException e) { e.printStackTrace(); }

Is this draft under consideration for inclusion in the 3.0 release?

For additional background, I saw this related post [elasticsearch - Is there a way to do Raw JSON Requests using the Opensearch Java Client? - Stack Overflow](https://stackoverflow.com/questions/76172055/is-there-a-way-to-do-raw-json-requests-using-the-opensearch-java-client)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [January 5, 2024, 4:19pm UTC](https://forum.opensearch.org/t/java-client-class-specification/16161/3 "2024-01-05T16:19:41Z")

</div>

Closed on January 5, 2024, 4:19pm UTC

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