Elasticsearch 基础操作

官方文档: https://www.elastic.co/guide/en/elasticsearch/reference/5.1/index.html
创建索引
~#curl -XPUT http://192.168.56.200:9200/test?pretty
关闭索引
~#curl -XPOST http://192.168.56.200:9200/test/_close?pretty
修改分词器
~#curl -XPUT 'http://192.168.56.200:9200/test/_settings?preserve_existing=true&pretty' -d '{"index.analysis.analyzer.default.type" : "ik_max_word"}'
修改 dynamic mapper 配置
~#curl -XPUT 'http://192.168.56.200:9200/test/_settings?pretty' -d '{"index.mapper.dynamic" : true}'
打开索引
~#curl -XPOST http://192.168.56.200:9200/test/_open?pretty
查看索引状态
~#curl -XGET http://192.168.56.200:9200/test?pretty
索引文档
~#curl -XPUT http://192.168.56.200:9200/test/test/1?pretty -d '{"country":"中华人民共和国","created_at":"1949-10-01T00:00:00"}'
根据条件删除文档
~#curl -XPOST http://192.168.56.200:9200/test/test/_delete_by_query?pretty -d '{"query":{"match_all":{}}}'
重建索引
~#curl -XPOST http://192.168.56.200:9200/_reindex?pretty -d '{"source": {"index": "test"}, "dest": {"index": "test_v2"} }'
创建别名
~#curl -XPOST http://192.168.56.200:9200/_aliases?pretty -d '{"actions" : [{ "add" : { "index" : "test", "alias" : "test_v1" } }] }'
删除别名
~#curl -XPOST http://192.168.56.200:9200/_aliases?pretty -d '{"actions" : [{ "remove" : { "index" : "test", "alias" : "test_v1" } }] }'
删除索引
~#curl -XDELETE http://192.168.56.200:9200/test?pretty

发表评论

电子邮件地址不会被公开。 必填项已用*标注