美文网首页
Elastic Search 基本操作 -- 创建索引

Elastic Search 基本操作 -- 创建索引

作者: 横渡 | 来源:发表于2019-06-13 12:06 被阅读0次

创建索引

创建一个people结构化索引。
方法:PUT
URL: http://192.168.217.135:9200/people
json报文,setting里面定义了分片和副本数,如果mapping非空表明是结构化索引
注意:elastic Search 6 以上版本,创建索引时只支持创建一个类型(Type),而以下版本创建索引的同时可以创建多个类型。

{
    "settings":{
        "number_of_shards": 3,
        "number_of_replicas": 1
    },
    "mappings": {
        "man": {
            "properties": {
                "name" : {
                    "type": "text"
                },
                "country": {
                    "type": "keyword"
                },
                "age": {
                    "type": "integer"
                },
                "date": {
                    "type": "date",
                    "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
                }
            }
        }
    }
}

相关文章

网友评论

      本文标题:Elastic Search 基本操作 -- 创建索引

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