linux 环境下,如何创建 es 索引

linux 环境下已经安装好了 elasticsearch 环境,在内网环境下如何创建索引?

1 个解决方案

AllenJiang
中间件研发,关注微信公众号 : 小哈学Java, 回复"666", 即可免费领取10G学习&面试资料

通过 ssh 客户端,可以通过 curl 命令来创建索引:

curl -XPUT 'http://localhost:9200/exception/' -d '{"settings": {"number_of_replicas": 0},
  "mappings": {
    "question": {
      "dynamic": false,
      "properties": {
        "questionId": {"type": "long"},
        "title": {
          "type": "text",
          "index": "analyzed",
          "analyzer": "ik_smart",
          "search_analyzer": "ik_smart"
        },
        "desc": {
          "type": "text",
          "index": "analyzed",
          "analyzer": "ik_smart",
          "search_analyzer": "ik_smart"
        },
        "createTime": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss||epoch_millis"
        },
        "viewNum": {"type": "integer"},
        "voteUp": {"type": "integer"},
        "voteDown": {"type": "integer"},
        "createUserId": {"type": "long"},
        "createUserName": {"type": "keyword"},
        "type": {"type": "integer"},
        "tags": {"type": "nested"}
      }
    }
  }
}'