ES (7.10.2)学习系列之 常用命令之index

231 阅读1分钟

Index

  • 删除索引 DELETE {{es-url}}/indexName
  • 获得索引信息 GET {{es-url}}/test-xizihao

出参

{
    "test-xizihao": {
        "aliases": {},
        "mappings": {
            "properties": {
                "age": {
                    "type": "long"
                },
                "birthday": {
                    "type": "date",
                    "format": "yyyy-MM-dd"
                },
                "birthday_time": {
                    "type": "date",
                    "format": "yyyy-MM-dd HH:mm:ss"
                },
                "id": {
                    "type": "long"
                },
                "interesting": {
                    "type": "text"
                },
                "name": {
                    "type": "keyword"
                }
            }
        },
        "settings": {
            "index": {
                "routing": {
                    "allocation": {
                        "include": {
                            "_tier_preference": "data_content"
                        }
                    }
                },
                "refresh_interval": "60s",
                "number_of_shards": "3",
                "provided_name": "test-xizihao",
                "creation_date": "1621416970158",
                "number_of_replicas": "1",
                "uuid": "wGVT7E-oSCeMHUNFQJ-ApQ",
                "version": {
                    "created": "7100299"
                }
            }
        }
    }
}
  • 创建索引 PUT {{es-url}}/indexName

入参

{
    "mappings": {
        "properties": {
            "age": {
                "type": "long"
            },
            "birthday": {
                "type": "date",
                "format": "yyyy-MM-dd"
            },
            "birthday_time": {
                "type": "date",
                "format": "yyyy-MM-dd HH:mm:ss"
            },
            "id": {
                "type": "long"
            },
            "interesting": {
                "type": "text"
            },
            "job": {
                "type": "keyword",
                "index": false
            },
            "name": {
                "type": "keyword"
            },
            "sex": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            },
            "company":{
                "type": "keyword"
            }
        }
    }
}