elasticsearch 创建 mapping

  • 查看当前ES中有哪些索引

    1
    2
    3
    4
    5
    6
    7
    8
    [GET] http://localhost:9200/_cat/indices

    返回:
    {
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "inde_name"
    }
  • 创建索引(index)(mysql-库)

    1
    2
    3
    4
    5
    6
    7
    8
    [PUT] http://localhost:9200/inde_name

    返回:
    {
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "inde_name"
    }
  • 查看索引

    1
    2
    3
    4
    5
    6
    7
    8
    [GET] http://localhost:9200/inde_name/_mapping

    返回:
    {
    "inde_name": {
    "mappings": {}
    }
    }
  • 创建类型(type)(mysql-表)的同时创建创建映射(mapping)(mysql-字段)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    [POST] http://localhost:9200/inde_name/_mapping/fans

    body:
    {
    "dynamic": "false",
    "_all": {
    "enabled": false
    },
    "_parent": {
    "type": "kol"
    },
    "_routing": {
    "required": true
    },
    "properties": {
    "fansAge": {
    "type": "integer"
    },
    "fansCity": {
    "type": "keyword"
    },
    "fansCityLevel": {
    "type": "integer"
    },
    "fansGender": {
    "type": "integer"
    },
    "fansInterests": {
    "type": "keyword"
    },
    "fansKolUid": {
    "type": "keyword"
    },
    "fansLocation": {
    "type": "keyword"
    },
    "fansProvince": {
    "type": "keyword"
    },
    "fansUid": {
    "type": "keyword"
    }
    }
    }

    返回:
    {
    "acknowledged": true,
    }
  • 再次查看索引

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    [GET] http://localhost:9200/inde_name/_mapping

    返回:
    {
    "inde_name": {
    "mappings": {
    "fans": {
    "dynamic": "false",
    "_all": {
    "enabled": false
    },
    "_parent": {
    "type": "kol"
    },
    "_routing": {
    "required": true
    },
    "properties": {
    "fansAge": {
    "type": "integer"
    },
    "fansCity": {
    "type": "keyword"
    },
    "fansCityLevel": {
    "type": "integer"
    },
    "fansGender": {
    "type": "integer"
    },
    "fansInterests": {
    "type": "keyword"
    },
    "fansKolUid": {
    "type": "keyword"
    },
    "fansLocation": {
    "type": "keyword"
    },
    "fansProvince": {
    "type": "keyword"
    },
    "fansUid": {
    "type": "keyword"
    }
    }
    }
    }
    }
    }