ElasticSearch索引创建

索引创建

{
	"settings": {
		"number_of_shards": 3,
		"number_of_replicas": 1
	},
	"mappings": {
		"man": {
			"properties": {
				"name": {
					"type": "text"
				},
				"country": {
					"type": "keyword"
				},
				"age": {
					"type": "integer"
				},
				"date": {
					"type": "date",
					"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
				}
			}
		},
		"woman": {
			
		}
	}
}
//参数介绍
number_of_shards 分片数
number_of_replicas 备份数
mappings 索引映射
man字段, properties为man字段下的映射属性
type为字段的类型

使用Postman提交索引创建请求
http://127.0.0.1:9200/people 创建people索引,PUT请求,请求参数json形式如上

修改索引的映射

{
	"novel": {
		"properties": {
			"author": {
				"type": "keyword"
			},
			"word_count": {
				"type": "integer"
			},
			"publish_date": {
				"type": "date",
				"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
			}
		}
	}
}

请求url http://127.0.0.1:9200/book/novel/_mapping 请求类型POST

你可能感兴趣的:(ElasticSearch)