elasticsearch RESTful

时间:2023-03-09 09:10:59
elasticsearch RESTful

一 、索引(index)

1. 创建索引

(1)第一种方式

PUT twitter
{
"settings" : {
"index" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
}

elasticsearch RESTful

(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" : { }
}
}

elasticsearch RESTful

2. 删除索引

DELETE /twitter

elasticsearch RESTful

二、结构(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"
}
}
}
}
}

elasticsearch RESTful

2. 下面的错误由于:elasticsearch 2.X不支持text,好像5.X才支持,2.X使用的是string

elasticsearch RESTful

3. 正常如下

elasticsearch RESTful

4. 添加mapping

elasticsearch RESTful

5. 查看mapping

elasticsearch RESTful

6. 添加mapping

{
"product": {
"properties": {
"amount":{
"type":"integer"
}
}
}
}

elasticsearch RESTful

7. 查看

elasticsearch RESTful

8. 修改mapping

http://www.cnblogs.com/Creator/p/3722408.html