索引的参数,分为两类:
- 静态参数,仅支持在创建索引时指定,或者关闭索引后指定。
- 动态参数,允许在索引工作期间指定或者修改。
静态参数
index.number_of_shards
默认值为1
。
本参数用于控制主分片的数量,仅支持在创建时指定,对于已关闭的索引,修改本参数不会生效。
es.index.max_number_of_shards
默认情况下,每个索引可以使用的分片的数量最大为1024
。
启动Elasticsearch
进程时,可以在命令行中修改参数值,命令样例,如下:
export ES_JAVA_OPTS="-Des.index.max_number_of_shards=128"
./bin/elasticsearch
index.number_of_routing_shards
拆分索引的路由分片数量,和索引主分片index.number_of_shards
的取值相关。
默认值位于2~1024之间。
index.codec
可选值为:
default
,默认选项,使用LZ4
算法对保存到盘上的数据执行压缩操作。best_compression
,使用DEFLATE算法对保存到盘上的数据执行压缩操作。
变更index.codec
的取值后,对后续的segment
合并操作生效,可以使用Force merge API强制触发合并操作。
index.routing_partition_size
仅允许在创建索引时指定,索引创建成功后,不支持修改。
默认值为1
,参数值需要小于index.number_of_shards
。
index.soft_deletes.enabled
默认值为true
。
指示软件删除是否启用,仅在创建索引时允许指定。
可选项,如下:
true
,默认值,支持软删除。false
,关闭软删除。
index.soft_deletes.retention_lease.period
默认值为12h
。
软删除的数据记录保持在shard
中的时长。
index.load_fixed_bitset_filters_eagerly
默认值为true
。
可选项,如下:
true
,默认值,启用预加载。false
,关闭预加载。
index.shard.check_on_startup
仅限专家使用,在调测问题时,在shard
启动过程中增加一些重型的检查操作。
建议完成问题处理后,及时关闭本选项。
可选项,如下:
false
,默认值,不启用额外的检查。checksum
,计算shard
关联的所有文件的校验和,校验一致性,评估数据是否存在物理上的损坏。true
,执行checksum
选项关联的检查操作,同时校验数据的逻辑上可能存在的损坏。
动态参数
index.number_of_replicas
默认值为1
。
索引的副本数量。
index.auto_expand_replicas
默认值为false
。
依据集群中节点的数量,自动扩展索引的副本的数量。
可选项,如下:
false
,默认行为,即不自动扩展副本的数量。- 区间,比如
0-5
,或者0-all
。
index.search.idle.after
默认值为30s
。
shard
的状态为空闲时,才能接收并处理检索请求。
本参数指定了等待shard
进入空闲状态的时长。
index.refresh_interval
默认值为1s
。
对索引的变更,只有执行刷新操作之后,才能被外部检索到。
本参数指定了后台执行的刷新操作的定时任务运行的时间间隔。
可选项,如下:
1s
,默认值。-1s
,禁用后台的刷新操作。
当本参数没有显式指定时,有如下行为:
- 处于空闲状态的
shard
不会响应刷新操作。 - 当处于空闲状态的
shard
收到查询请求时,主动触发一次刷新操作,然后再执行查询操作。
index.max_result_window
默认值为10000
。
使用from + size
方式检索数据时,本参数用于控制返回结果的记录的数量。
检索操作占用的JVM堆内存和消耗的时间,和from + size
的值正相关,使用本参数可有效控制前述资源的占用量。
假如需要获取更多的检索结果,需要考虑使用scroll或者search-after。
index.max_inner_result_window
默认值为100
。
使用from + size
方式检索数据时,本参数用于限制检索操作占用的JVM堆内存和消耗的时间。
index.max_rescore_window
检索请求参数中window_size
字段取值的上限,默认值与index.max_result_window
的取值相同。
本参数用于限制检索操作占用的JVM堆内存和消耗的时间。
index.max_docvalue_fields_search
默认值为100
。
在查询请求中,docvalue_field
个数的上限。
index.max_script_fields
默认值为32
。
在查询请求中,script_field
个数的上限。
index.max_ngram_diff
默认值为1
。
对于NGramTokenizer
和NGramTokenFilter
,min_gram
和max_gram
之间差值的最大值。
index.max_shingle_diff
默认值为3
。
max_shingle_size
和min_shingle_size
之间差值的最大值。
index.max_refresh_listeners
在索引的每个shard
上允许指定的listener
数量的上限。
index.analyze.max_token_count
默认值为10000
。
使用_analyze
API时支持的Token
的最大数量。
index.highlight.max_analyzed_offset
默认值为1000000
。
在highlight request
时允许被分析的字符的最大数量。
index.max_terms_count
默认值为65536
。
使用Terms Query
时,允许使用的条件的最大数量。
index.max_regex_length
默认值为1000
。
使用Regexp Query
时,允许使用的正则表达式的最大长度。
index.query.default_field
控制如下类型的查询操作允许生效的字段。
index.routing.allocation.enable
指示是否启用shard
的分配能力。
可选值,如下:
all
,默认值,全部shard
支持分配。primaries
,主shard
支持分配。new_primaries
,仅有新创建的shard
支持分配。none
,所有shard
禁止分配。
index.routing.rebalance.enable
指示是否启用shard
的再平衡能力。
可选值,如下:
all
,默认值,全部shard
启用再平衡能力。primaries
,只针对主shard
启用再平衡能力。replicas
,只针对副本的shard
启用再平衡能力。none
,关闭shard
的再平衡能力。
index.gc_deletes
被删除的数据记录,其版本号仍然可用的时长。
默认值为60s
。
index.default_pipeline
默认的ingest pipeline
对象。
_none
是特殊的pipeline
对象,表示空的pipeline
对象。
index.final_pipeline
最后的ingest pipeline
对象。
在request pipeline
和default pipeline
之后运行,本参数指定的pipeline
必须可用,否则将导致索引相关的操作失败。
_none
是特殊的pipeline
对象,表示空的pipeline
对象。
index.hidden
使用模糊匹配时,是否隐藏本索引对象的相关信息。
可选值,如下:
true
,即开启模糊匹配时,本索引被隐藏。false
,默认值,即开启模糊匹配时,允许本索引被匹配到,并返回相关信息。
相关资料
- Index modules
- Open index API
- Update index settings API
- Force merge API
- _routing field
- Delete API
- Index API
- Query and filter context
- DEFLATE
- Split index API
- Breaking changes in 7.0
- Term-level queries
- ?refresh
- Shingle token filter
- Indexing pressure
- 3、Elasticsearch cluster, node, index, document, shards 及 replica概念
- Elasticsearch创建一个索引怎么也这么复杂
- index 配置
- elasticsearch详细使用教程
- Elasticsearch-索引(Index)
- Elasticsearch7——索引模块
- Elasticsearch Index模块
- ES7.5 下动态扩大索引的shard数量
- ElasticSearch modules Indexelasticsearch modules index elasticsearch index api get elasticsearch index open api elasticsearch logstash could index elasticsearch settings index api elasticsearch analyze index usage elasticsearch index stats api elasticsearch clone index api elasticsearch close index api elasticsearch delete index api