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
本文所用测试工具:火狐插件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
相关文章推荐
- ascii文件转为utf-8格式
- HBase概念学习(九)HTablePool为何弃用?
- 《Javascript高级程序设计》读书笔记之——基本包装类型
- iOS 里面 Swift与Objective-C混编,Swift与C++混编的一些比较
- POJ 百练1011 STICKS
- [置顶] 用递归算法得到Java的树形结构
- 三栏式布局
- Sharepoint 2013 出现The tool was unable to install Application Server Role, Web Server (IIS) Role
- icon右上角显示数字 ios8.0
- Xcode6:The file couldn’t be opened because you don’t have permission to view it
- 腾讯Bugly 最专业的质量跟踪平台(用于跟踪、收集ANR和崩溃)
- 如何在不切换 Activity的同时切换页面布局
- Poj 2406(同1961)
- jQuery 之 隐藏显示与淡入淡出效果(三)
- hdu 1051 Wooden Sticks
- python 参数
- Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'
- enjoy java8 section3
- 将一个从大到小的数组,用以下排序方法排序成从小到大的,()最快。----阿里巴巴2015实习生笔试题
- 存钱问题