为了学习elasticsearch,跟着官方文档及网上例子操作了一些,整理记录下来,以供大家参考。
本文所用测试工具:火狐插件HttpRequester。
elasticsearch:2.3
----------------------------------------创建index---------------------------------------------
Content-Type: application/json
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 21
{"acknowledged":true}
----------------------------------------查询index---------------------------------------------
-- 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---------------------------------------------
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---------------------------------------------
-- 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
只能添加字段,不能修改和删除字段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---------------------------------------------
-- 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---------------------------------------------
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(==防止爬虫==):http://blog.liuyingguang.cn