gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 01:23:46 24 4
gpt4 key购买 nike

我正在尝试向我的映射对象添加带有小写选项的规范化器,因为它是在官方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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com