您的位置:首页 > 其它

elasticsearch创建index和type操作日志记录

2016-07-08 18:15 525 查看
为了学习elasticsearch,跟着官方文档及网上例子操作了一些,整理记录下来,以供大家参考。
本文所用测试工具:火狐插件HttpRequester。

elasticsearch:2.3

----------------------------------------创建index---------------------------------------------

POST http://192.168.10.139:9200/megacorp1/
Content-Type: application/json

-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 21

{"acknowledged":true}

----------------------------------------查询index---------------------------------------------

GET http://192.168.10.139:9200/megacorp1/?pretty

-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 361

{
"megacorp1" : {
"aliases" : { },
"mappings" : { },
"settings" : {
"index" : {
"creation_date" : "1467844960627",
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "3luuvHNGSf2RBYJHxRGUNg",
"version" : {
"created" : "2030399"
}
}
},
"warmers" : { }
}
}

----------------------------------------创建type---------------------------------------------

POST http://192.168.10.139:9200/megacorp1/_mapping/type1
Content-Type: application/json
{
"properties": {
"text": {
"type": "string",
"analyzer": "standard",
"search_analyzer": "whitespace"
}
}
}
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 21

{"acknowledged":true}

----------------------------------------查询type---------------------------------------------

GET http://192.168.10.139:9200/megacorp1/_mapping/type1?pretty

-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 258

{
"megacorp1" : {
"mappings" : {
"type1" : {
"properties" : {
"text" : {
"type" : "string",
"analyzer" : "standard",
"search_analyzer" : "whitespace"
}
}
}
}
}
}

----------------------------------------修改type

只能添加字段,不能修改和删除字段

POST http://192.168.10.139:9200/megacorp1/_mapping/type1?pretty
Content-Type: application/json
{
"properties": {
"text": {
"type": "string",
"analyzer": "standard",
"search_analyzer": "whitespace"
},"text1": {
"type": "string",
"analyzer": "standard",
"search_analyzer": "whitespace"
}
}
}
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 28

{
"acknowledged" : true
}

----------------------------------------查询type---------------------------------------------

GET http://192.168.10.139:9200/megacorp1/_mapping/type1?pretty

-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 406

{
"megacorp1" : {
"mappings" : {
"type1" : {
"properties" : {
"text" : {
"type" : "string",
"analyzer" : "standard",
"search_analyzer" : "whitespace"
},
"text1" : {
"type" : "string",
"analyzer" : "standard",
"search_analyzer" : "whitespace"
}
}
}
}
}
}

----------------------------------------删除type---------------------------------------------

esasticSearch2.0中,mapping不再支持删除,

参考:http://elasticsearch.cn/question/234
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: