简体   繁体   中英

ElasticSearch - index change not flushed

I use the elasticsearch module in typescript, and for some reason, the changes I apply to the indexes (or even the new documents I insert) are not detected by the code...

Here's an example bellow:

        try {
            await this._client.indices.delete({
                index: 'databases, schemas, tables',
                ignore_unavailable: true
            });
        } catch (err) {
            console.error('Error trying to delete the indexes...');
            console.error(err);
        }

        try {
            await this._client.indices.create({ index: 'databases' });
            await this._client.indices.create({ index: 'schemas' });
            await this._client.indices.create({ index: 'tables' });
        } catch (err) {
            console.error('Error trying to create the indexes...');
            console.error(err);
        }

        try {
            await this._client.indices.flush({
                index: 'databases, schemas, tables',
            });
        } catch (err) {
            console.error('Error trying to flush...');
            console.error(err);
        }

The result of this code is:

Error trying to create the indexes...
ResponseError: resource_already_exists_exception
...

Error trying to flush...
ResponseError: index_not_found_exception
...

So this really makes no sense to me.. Am i missing something obvious?

You seem to be flushing indexes with a comma delimited string, you should try passing the list of indexes as an array:

await this._client.indices.flush({
                index: ['databases', 'schemas', 'tables']
            })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM