avatar
童琦杰
Dec 27, 2021Technology

Elasticsearch API

创建索引

bash
curl --request PUT 'es/test-logging'

创建成功响应

json
{"acknowledged":true,"shards_acknowledged":true,"index":"test-logging"}

删除索引

bash
curl --request DELETE 'es/test-logging'

删除成功响应

json
{"acknowledged":true}

设置字段动态映射

bash
curl --request PUT 'es/test-logging/_mapping' \
--header 'Content-Type: application/json' \
--data-raw '{
    "dynamic": true
}'

设置成功响应

json
{"acknowledged":true}

创建字段

keyword类型字段

bash
curl --request PUT 'es/test-logging/_mapping' \
--header 'Content-Type: application/json' \
--data-raw '{
    "properties": {
        "name": {
            "type": "keyword"
        }
    }
}'

成功响应

json
{"acknowledged":true}

date类型字段

bash
curl --request PUT 'es/test-logging/_mapping' \
--header 'Content-Type: application/json' \
--data-raw '{
    "properties": {
        "time": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss.SSS"
        }
    }
}'

float类型字段

bash
curl --request PUT 'es/test-logging/_mapping' \
--header 'Content-Type: application/json' \
--data-raw '{
    "properties": {
        "number": {
            "type": "float"
        }
    }
}'
© 2015-2022 tongqijie.com 版权所有沪ICP备17000682号