创建索引(及映射)

PUT apple
{
	"settings": {
		"number_of_shards": 5,
		"number_of_replicas": 1
	},
	"mappings": {
		"apple_type": {
			"properties": {
				"id": {
					"type": "long"
				},
				"code": {
					"type": "keyword"
				},
				"unit": {
					"type": "keyword"
				},
				"price": {
					"type": "integer"
				},
				"create_time": {
					"type": "date"
				},
				"create_user": {
					"type": "keyword"
				}
			}
		}
	}
}

注意两个String类型

ES在5.0以后对String类型做了细分:

keyword:不进行分词,直接索引;

text:会分词,然后进行索引;

你可能感兴趣的:(ElasticSearch)