1、简单创建索引
#lcoalhost可以换成http://ip
curl -XPUT 'localhost:9255/rumor/'
2、带参数创建索引(这里只指定replica数,可以指定更多的参数)
curl -XPUT 'localhost:9255/rumor' -d '
{
"settings": {
}
}
'
注意事项: number_of_replicas设置成(机器数-1),不然es页面会显示UNassign shards,集群健康值不正常
3、添加mapping
#lcoalhost可以换成http://ip
curl -XPUT 'localhost:9255/rumor/_mapping/rumor' -d '
{
"properties": {
"rumor": {
"analyzer": "whitespace",
"type": "string"
},
"deny": {
"index": "not_analyzed",
"type": "string"
},
"words": {
"type": "string"
},
}
}
{
"properties": {
"rumor": {
"analyzer": "whitespace",
"type": "string"
},
"deny": {
"index": "not_analyzed",
"type": "string"
},
"words": {
"type": "string"
},
}
}
'
4、删除索引
curl -XDELETE 'localhost:9255/rumor/'