# Querying AWS OpenSearch low level client

**URL:** <https://forum.opensearch.org/t/querying-aws-opensearch-low-level-client/18852>\
**Category:** OpenSearch\
**Tags:** troubleshoot\
**Created:** [April 12, 2024, 12:51pm UTC](https://forum.opensearch.org/t/querying-aws-opensearch-low-level-client/18852 "2024-04-12T12:51:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kushagra\_Palof](https://avatars.discourse-cdn.com/v4/letter/k/8e8cbc/32.png) [@Kushagra\_Palof](https://forum.opensearch.org/u/Kushagra_Palof)\
**Post date:** [April 12, 2024, 12:51pm UTC](https://forum.opensearch.org/t/querying-aws-opensearch-low-level-client/18852/1 "2024-04-12T12:51:14Z")

</div>

I am using OpenSearch Java client to connect to my AWS endpoint.

```auto
        OpenSearchClient client = new OpenSearchClient(
                new AwsSdk2Transport(
                        httpClient,
                        domainName,
                        "es",
                        Region.EU_WEST_1,
                        AwsSdk2TransportOptions.builder()
                                .setCredentials(credentialsProvider)
                                .build()
                )
       );

```

I have a multi line bool query that I want to pass in SearchRequest Object. I converted the Json String of the Query to a Java BoolQueryBuilder object. Is there any way to pass this object in my search request? Or can I directly use the Json query String some how?

My example query:

```auto
        query: {
          bool: {
            filter: [
              {
                bool: {
                  minimum_should_match: 1,
                  should: [
                    {
                      nested: {
                        path: "<some-path>",
                        query: {
                          bool: {
                            minimum_should_match: 1,
                            should: [
                              {
                                terms: {
                                  "<some-term>": ['int-value'],
                                },
                              },
                              {
                                terms: {
                                  "<some-term>": [],
                                },
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      nested: {
                        path: "<some-path>",
                        query: {
                          bool: {
                            minimum_should_match: 1,
                            should: [
                              {
                                terms: {
                                 <term>,
                                },
                              },
                              {
                                terms: {
                                  "<some-term>": [],
                                },
                              },
                            ],
                          },
                        },
                      },
                    },
                    {
                      nested: {
                        path: "<path>",
                        query: {
                          bool: {
                            minimum_should_match: 1,
                            should: [
                              {
                                terms: {
                                  "<some-term>": [68],
                                },
                              },
                              {
                                terms: {
                                  "<some-term>": [],
                                },
                              },
                            ],
                          },
                        },
                      },
                    },
                  ],
                },
             

```

---

<div class="post-metadata">

**Author:** ![gaobinlong](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/gaobinlong/32/5242_2.png) [@gaobinlong](https://forum.opensearch.org/u/gaobinlong)\
**Post date:** [April 15, 2024, 10:35am UTC](https://forum.opensearch.org/t/querying-aws-opensearch-low-level-client/18852/2 "2024-04-15T10:35:51Z")

</div>

Unlike the high level reset client, the java client has its own way to build a searchRequest, something like this:

```auto
SearchRequest searchRequest = new SearchRequest.Builder().query(
                q -> q.match(m -> m.field("text").query(FieldValue.of("Text for document 2")))
            ).build();

```

, you can see some examples here: [opensearch-java/guides/search.md at main · opensearch-project/opensearch-java · GitHub](https://github.com/opensearch-project/opensearch-java/blob/main/guides/search.md).
