# Nodejs opensearch client: how to useSQL

**URL:** <https://forum.opensearch.org/t/nodejs-opensearch-client-how-to-usesql/7682>\
**Category:** OpenSearch Client Libraries\
**Tags:** opensearch-js\
**Created:** [November 18, 2021, 9:43pm UTC](https://forum.opensearch.org/t/nodejs-opensearch-client-how-to-usesql/7682 "2021-11-18T21:43:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdeboer](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@bdeboer](https://forum.opensearch.org/u/bdeboer)\
**Post date:** [November 18, 2021, 9:43pm UTC](https://forum.opensearch.org/t/nodejs-opensearch-client-how-to-usesql/7682/1 "2021-11-18T21:43:14Z")

</div>

I’m converting from the elasticsearch to the opensearch nodejs library, and I’m struggling to get SQL queries to work.

I have:

```auto
import * as os from "@opensearch-project/opensearch"

const client = new os.Client({...})
await client.search({
    method: "POST",
    path: "/_plugins/_sql",
    body: {
      query: "select * from my_index"
    }
  })

```

This fails with “no overload matches this call”. It seems “method” is recognised, but path isn’t. Any suggestions?

In case I find the answer, I’ll post back here, but as this isn’t obvious, I thought I might as well put a topic here so others can find it.

If I remove path, the error response is: `ResponseError: parsing_exception: [parsing_exception] Reason: Unknown key for a VALUE_STRING in [query].`

---

<div class="post-metadata">

**Author:** ![bdeboer](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@bdeboer](https://forum.opensearch.org/u/bdeboer)\
**Post date:** [November 19, 2021, 1:50am UTC](https://forum.opensearch.org/t/nodejs-opensearch-client-how-to-usesql/7682/2 "2021-11-19T01:50:29Z")

</div>

Found the answer:

```auto
  const { body } = await client.transport.request({
    method: "POST",
    path: "_plugins/_sql",
    body: {
      query: "select * from my_index"
    }
  })

```
