Is there any way to use client.search() in elastic clients(node.js) without index parameter

I have an account that only accessible to an index.
So index name had to be written in node.url for avoiding security exception
but I got error code 400(bad Request) instead of security Exception,
because of missing index name in const body.

Is there any way to get search result without providing index name in client.search?
please refer my node.js codes as following

const { Client } = require('@elastic/elasticsearch');
const { URL } = require('url');

const client = new Client({
    node: {
        url: new URL('https://sample.example.com/myindex'), //without index name, I got a security exception 
        username: 'test',
        password: 'test',
    
    },
});

async function run() {

  // Let's search!
    const { body } = await client.search({
        //  index: '', //It's already written in node.URL
        type: '_docs', 
        body: { //to get all data
           
        },
    });

    console.log('The body content : ' + body.hits.hits);
}

run().catch(console.log);

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