1

我想在模板设置中增加 elasticsearch 的缓冲区大小,但是我应该在哪里添加这个设置。我应该在哪里写indices.memory.index_buffer_size:?据我了解,它应该为索引定义,实际上我有一个索引。

const indexTemplateSettings = {
    number_of_shards: 2,
    number_of_replicas : 0,
    refresh_interval: '3600s',
    'indices.memory.index_buffer_size': '30%',
    // 'store.throttle.max_bytes_per_sec' : '100mb',
    max_result_window: 1000000000,
    'index.routing.allocation.enable': 'all',
}

export const init = async types => {
    try {
        let client = createClient()

        const templateSettings = {
            index_patterns : ['*'],
            settings: indexTemplateSettings,
            mappings : types.reduce((p, type) => ({
                ...p,
                [type] : {
                    numeric_detection: true,
                    _source : {enabled : true},
                    dynamic_templates: [
                        {
                            all: {
                                match: '*',
                                mapping: {
                                    copy_to: searchField,
                                },
                            },
                        },
                    ],
                    properties: {
                        _searchField: {
                            type: 'text',
                        },
                    },
                },
            }), {}),
        }

        await client.indices.putTemplate({
            name: 'default',
            body: templateSettings,
        },(error, response) => {
            logger.silly('Pushing of index template completed', response)
        })
    } catch (e) {
        logger.error(e)
    }
}
4

1 回答 1

1

这应该转到elasticsearch.yml配置文件。引用相关文档

以下设置是静态的,必须在集群中的每个数据节点上进行配置

默认为堆的 10%。这是一个节点范围的设置,而不是基于每个索引的设置。

附带说明:这应该是每个分片 512MB 的最大值,如 docs 中所述

于 2018-04-15T10:01:29.130 回答