** 初始化其映射**html
PUT /my_index/_mapping/my_type { "my_type": {//索引字段 "properties": {// "english_title": { "type": "string",//字段的类型,string类型 "analyzer": "english"//分析方式 } } } } //上面这种方式,是之前旧的方式。如今都使用这种的方式建立字段 PUT /my_index/_mapping/my_type { "my_type": { "properties": { "english_title": { "type": "keyword" //不分词结构, } } } } //type也有分词索引结构的字段,就是text类型的字段
ES中的基本数据类型有数组
一样咱们能够使用其余数据类型来构建咱们的数据映射
咱们在建立索引时,也能够指定其余的设置,例如自定义分片方式app
PUT /my_temp_index { "settings": { "number_of_shards" : 1,//主分片数量 "number_of_replicas" : 0//副分片数量 } }
咱们也能够在建立索引,同时自定义分词结构elasticsearch
PUT /product { "settings": { "analysis": { "analyzer": { "defalut": { "tokenizer": "ik_max_word" }, "pinyin_analyzer": { "tokenizer": "my_pinyin" } }, "tokenizer": { "my_pinyin": { "keep_first_letter": false, "keep_full_pinyin": true, "keep_original": false, "keep_separate_first_letter": false, "limit_first_letter_length": 16, "lowercase": true, "type": "pinyin" } } } } }, 这上面的分词器须要先安装,这是利用安装后ik分词器来进行分词结构