
一 、索引(index)
1. 创建索引
(1)第一种方式
PUT twitter
{
"settings" : {
"index" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
}
(2)第二种方式
①:没有指定mapping
curl -XPOST "http://127.0.0.1:9200/productindex"
{"acknowledged":true}
②:查看mapping
curl -XGET "http://127.0.0.1:9200/productindex/_mapping?pretty"
{
"productindex" : {
"mappings" : { }
}
}
2. 删除索引
DELETE /twitter
二、结构(map)
1. 创建index的过程中创建mapper,如果已经存在则报如下错误
PUT index_an
{
"mappings": {
"egan": {
"properties": {
"title": { "type": "string" },
"name": { "type": "string" },
"age": { "type": "integer" },
"created": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
}
}
}
}
}
2. 下面的错误由于:elasticsearch 2.X不支持text,好像5.X才支持,2.X使用的是string
3. 正常如下
4. 添加mapping
5. 查看mapping
6. 添加mapping
{
"product": {
"properties": {
"amount":{
"type":"integer"
}
}
}
}
7. 查看
8. 修改mapping
http://www.cnblogs.com/Creator/p/3722408.html