美文网首页
Elasticsearch(ES) 相关操作

Elasticsearch(ES) 相关操作

作者: 小影哈哈 | 来源:发表于2020-05-12 16:01 被阅读0次

以下操作均在postman中操作

1. 创建索引

1.1请求地址
http://127.0.0.1:9200/test_index?pretty
1.2请求方式
PUT
1.3请求体
{
    "settings": {
        "number_of_shards": 3,
        "number_of_replicas": 2
    },
    "mappings": {
        "test_type": {
            "properties": {
                "id": {
                    "type": "long"
                },
                "name": {
                    "type": "text"
                },
                "url": {
                    "type": "keyword"
                },
                "price": {
                    "type": "double"
                }
            }
        }
    }
}
test_index:索引名称
test_type:索引类型
properties:字段及其类型
number_of_shards:分片数量
number_of_replicas:副本数量

2. 修改索引(增加字段)

2.1 请求地址
http://127.0.0.1:9200/test_index/_mapping/test_type
2.2 请求方式
POST
2.3 请求体
{
  "properties": {
    "desc": {
      "fielddata": true,
      "analyzer": "keyword",
      "type": "text"
    }
  }
}
在 test_type 下,增加 desc 属性

3.删除索引

3.1请求地址
http://127.0.0.1:9200/test_index
3.2 请求方式
DELETE

相关文章

网友评论

      本文标题:Elasticsearch(ES) 相关操作

      本文链接:https://www.haomeiwen.com/subject/upwbnhtx.html