【问题标题】:ElasticSearch - index change not flushedElasticSearch - 未刷新索引更改
【发布时间】:2020-07-26 06:05:06
【问题描述】:

我在 typescript 中使用了 elasticsearch 模块,由于某种原因,我对索引应用的更改(甚至我插入的新文档)没有被代码检测到...

下面是一个例子:

        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);
        }

这段代码的结果是:

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

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

所以这对我来说真的没有意义..我错过了一些明显的东西吗?

【问题讨论】:

    标签: node.js typescript elasticsearch node-modules


    【解决方案1】:

    您似乎正在用逗号分隔的字符串刷新索引,您应该尝试将索引列表作为数组传递:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-14
      • 2023-03-10
      • 2016-11-09
      相关资源
      最近更新 更多