javascript - 如何将小写规范化器添加到Elasticsearch映射对象?

标签 javascript node.js elasticsearch

我正在尝试向我的映射对象添加带有小写选项的规范化器,因为它是在官方Elasticsearch documentation中编写的

这是我的映射对象:

const schema = {
    date: {
        type: 'date'
    },
    user: {
        type: 'keyword'
    },
    environment: {
        type: 'text'
    }
};

const mappingBodySchema = {
    settings: {
        analysis: {
            normalizer: {
                logsNormalizer: {
                    // eslint-disable-next-line camelcase
                    filter: ['lowercase']
                }
            }
        }
    },
    mappings: {
        properties: schema
    }
};

还有我用来设置日志的来自elastic-js-client的函数:
await esclient.indices.putMapping({
      index,
      body: mappingBodySchema
    });

但是我收到以下错误:ResponseError: mapper_parsing_exception

有人可以建议我如何将规范化器正确添加到映射对象吗?

最佳答案

我发现了如何通过elasticsearch-js-client添加映射:

/*
 * Closing index to change its settings
 * (A closed index is blocked for read/write operations and does not allow all operations that opened indices allow.)
 */
await esclient.indices.close({
    index
});

await esclient.indices.putSettings({
    index,
    body: mapSettings
});

// Opening index after settings update - allows to perform read/write operations
await esclient.indices.open({
    index
});

// Specifying the mapping object of our log
await esclient.indices.putMapping({
    index,
    body: {
        properties: schema
    }
});

关于javascript - 如何将小写规范化器添加到Elasticsearch映射对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59096534/

相关文章:

javascript - 原型(prototype)对象可以从实例更改

elasticsearch - Elasticsearch 中的查询与过滤器

javascript - 编译 CoffeeScript 时如何保留目录结构?

javascript - 这条线有什么问题吗?

node.js - Sequelize 销毁函数是如何工作的?

javascript - 引导 Strapi 角色权限

angularjs - 如何在单个服务器上提供多个前端(AngularJS)应用程序和1个后端(Laravel)应用程序?

python - 如何获得 helpers.bulk 函数(elasticsearch API)的 python 响应?

python - Elasticsearch 没有给出准确的结果python

javascript - 在 css javascript 方法中使用变量