当前位置:   article > 正文

ElasticSearch索引创建_elasticsearch创建索引

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为字段的类型
  • 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

使用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"
			}
		}
	}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/843132
推荐阅读
相关标签
  

闽ICP备14008679号