阅读elastic search index module文档
This commit is contained in:
79
elastic search/02_elastic_search_index.md
Normal file
79
elastic search/02_elastic_search_index.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# index modules
|
||||
## index module introduce
|
||||
index module用于对索引进行创建,并且控制和索引相关的各个方面。
|
||||
|
||||
### 索引设置
|
||||
索引级别的设置可以针对每个索引来进行设置,设置分类如下:
|
||||
- static:static设置只能在如下时机应用于索引
|
||||
- 索引创建时
|
||||
- 索引处于closed状态
|
||||
- 使用`update-index-settings` api,并且带有`reopen=true`的查询参数,带有该参数时,会关闭受影响索引,更新后将受影响索引重新开启
|
||||
- dynamic:dynamic索引可以在索引处于活跃状态时,通过`udpate-index-settings` api进行修改
|
||||
|
||||
> #### closed index
|
||||
> 当一个索引处于`closed`状态时,所有针对该索引的read/write操作都会被阻塞,所有可以用于`opened`状态索引的操作,其执行对于`closed`状态的索引来说都不允许。
|
||||
>
|
||||
> 对于`closed`状态的索引,既无法向其中新增文档,也无法在索引中检索文档。
|
||||
>
|
||||
> 处于closed状态的索引能够通过`open index api`来重新开启。
|
||||
|
||||
### static index settings
|
||||
#### `index.number_of_shards`
|
||||
索引拥有的primary shards数量,默认为1,该配置项只能在索引创建时被设置。`即使索引处于closed状态,该配置项也无法修改。`
|
||||
|
||||
> `index.number_of_shards`最大为1024
|
||||
|
||||
## Analysis
|
||||
index analysis module充当了可配置的analyzer注册中心,analyzer可用于将`string`类型字段转换为独立的terms,这将用于:
|
||||
- 将文档string field的字段转化为terms,并且将terms添加到倒排索引中,令文档可以被搜索
|
||||
- analyzer被用于高级查询,例如`match`查询,将用户输入的查询字符串分割为search terms用于查询
|
||||
|
||||
## index shard allocation
|
||||
index shard allocation提供了可针对单个索引的设置,用于控制node中shard的分配:
|
||||
- shard allocating filtering:控制shard被分配给哪个node
|
||||
- delayed allocation:`节点离开导致未分配shard`的延迟分配
|
||||
- total shards per node:相同索引在同一node中,shards数量的上限
|
||||
- data tier allocation:控制对data tier分配的索引
|
||||
|
||||
## index blocks
|
||||
index blocks限制了针对特定索引的操作类型。操作阻塞的类型可以分为:
|
||||
- 读操作阻塞
|
||||
- 写操作阻塞
|
||||
- 元数据操作阻塞
|
||||
|
||||
针对索引操作的阻塞可以通过`dynamic index setting`来进行新增和移除。并且,阻塞也可以通过特定的api来进行添加和移除。
|
||||
|
||||
针对wrtie blocks设置的修改,一旦修改成功,那么所有的在途写操作都已经完成。
|
||||
|
||||
### index block settings
|
||||
#### `index.blocks.read_only`
|
||||
如果该配置项设置为true,该索引和索引的元数据都是只读的,当设置为`false`时,允许写操作和元数据变更。
|
||||
|
||||
#### `index.blocks.read_only_allow_delete`
|
||||
类似于`index.blocks.write`,但是可以对index进行删除。不要针对`index.blocks.read_only_allow_delete`进行手动设置或移除。`disk-based shard allocator`会根据磁盘剩余空间自动添加或移除该配置项。
|
||||
|
||||
从索引中删除文档释放资源(而不是删除索引本身)会暂时增加索引的大小,故而在node的磁盘空间不足时可能无法实现。当`index.blocks.read_only_allow_delete`被设置为true时,`并不允许删除索引中的文档`。但是,删除索引本身的操作只需要极少量的额外磁盘空间,并且几乎可以立即删除索引所占用的空间,故而删除索引本身的操作仍然被允许。
|
||||
|
||||
> elastic search在磁盘占用高于`flood stage watermark`时,会自动为索引增加` read-only-allow-delete`阻塞;当磁盘占用率跌倒`high watermark`之下时,则是会自动释放该阻塞
|
||||
|
||||
#### `index.blocks.read`
|
||||
如果设置为true,会阻塞针对index的读操作
|
||||
|
||||
#### `index.blocks.write`
|
||||
如果设置为true,会阻塞针对索引的写操作,和`index.blocks.read_only`不同,本设置项并不影响metadata。
|
||||
|
||||
例如,为索引设置write block后,仍然可以对metadata进行变更,但是设置了`index.blocks.read_only`后,无法对元数据进行变更
|
||||
|
||||
#### `index.blocks.metadata`
|
||||
如果设置为true,会禁止对元数据的读取和变更
|
||||
|
||||
### 增加index block示例
|
||||
```bash
|
||||
# PUT /<index>/_block/<block>
|
||||
PUT /my-index-000001/_block/write
|
||||
```
|
||||
参数示例:
|
||||
- `index`: 由`,`分隔的列表或通配符表达式,代表该请求的索引名称
|
||||
- 默认情况下,需要显式指定
|
||||
|
||||
|
||||
Reference in New Issue
Block a user