创建索引vw_common_prod_v1
curl -XPUT 'http://hd-1:9200/vw_common_prod_v1/' -d '{
"settings":{
"index":{
"number_of_shards":1,
"number_of_replicas":0
}
}
}'
number_of_shards 分片数
number_of_replicas 副本数
查看索引
curl 'hd-1:9200/_cat/indices?v'
删除索引
curl -XDELETE 'hd-1:9200/vw_common_prod_v1?pretty'
创建type:test1
curl -XPUT 'http://hd-1:9200/vw_common_prod_v1/_mapping/test1' -d '{
"properties" : {
"timestamp" : {
"type" : "date"
},
"message" : {
"type" : "string"
}
}
}'
增加文档
curl -XPUT ‘http://hd-1:9200/vw_common_prod_v1/prod/1’ -d ‘
{ “user”:”kimchy”, “post_date”:”2012-12-12”, “message”:”trying out ElasticSearch!”}’
有中文字符
curl -XPOST -H "'Content-type':'application/x-www-form-urlencoded', 'charset':'utf-8', 'Accept': 'text/plain'" hd-1:9200/vw_common_prod_v1/prod/2 -d'
{"PURCHASER":"美国留给伊拉克的是个烂摊子吗"}
查看type的mapping
curl -XGET hd-1:9200/vw_common_prod_v1/_mapping/prod?pretty
创建索引及type
curl -XPUT 'http://localhost:9200/index_name/' -d '
{
"settings":{
"index":{
"number_of_shards":1,
"number_of_replicas":0
}
},
"mappings": {
"type_one": {
"properties": {
"text": {
"type": "string",
"analyzer": "standard"
}
}
},
"type_two": {
"properties": {
"text": {
"type": "string",
"analyzer": "standard"
}
}
}
}
}'
参考文档:
http://www.tuicool.com/articles/26bIj2
http://blog.csdn.net/cnweike/article/details/33736429