您的位置:首页 > 移动开发

Elasticsearch创建索引,删除索引,添加mapping

2018-01-02 18:51 656 查看
1、简单创建索引
#lcoalhost可以换成http://ip

curl -XPUT 'localhost:9255/rumor/'   

2、带参数创建索引(这里只指定replica数,可以指定更多的参数)

curl -XPUT 'localhost:9255/rumor' -d '

{

  "settings": {

    "number_of_replicas":0

  }
}
'
注意事项: 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"

    },

  }

}

'
4、删除索引
curl -XDELETE 'localhost:9255/rumor/'   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ES
相关文章推荐