创建索引
索引名限制
起个正常点的名字。
- 只能是小写 Lowercase only
- 不能包含
\, /, *, ?, ", <, >, |, ` ` (space character), ,, #
这些鬼 - 不建议使用
:
- 不能以
-, _, +
- 不能包含
.
- 长度不能超过255字节
索引设置
创建索引可以进行特别设置,如下:
PUT twitter
{
"settings" : {
"index" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
}
默认的分片数为5,副本数为1。
也可以简单点设置,如下:
PUT twitter
{
"settings" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
映射
PUT test
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"_doc" : {
"properties" : {
"field1" : { "type" : "text" }
}
}
}
}
别名Aliases
PUT test
{
"aliases" : {
"alias_1" : {},
"alias_2" : {
"filter" : {
"term" : {"user" : "kimchy" }
},
"routing" : "kimchy"
}
}
}