ElasticSearch入门课程范例

一、创建索引操作

操作类型:PUT

操作地址:http://127.0.0.1:9200/people

{
	"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": {
			
		}
	}
}

二、插入数据操作

1)

操作类型:PUT

操作地址:http://127.0.0.1:9200/people/man/1

操作说明:people是索引、man是类型、1是指定文档ID。

{
	"name": "瓦力",
	"country": "China",
	"age": 30,
	"date": "1980-08-02"
}

2)

操作类型:POST

操作地址:http://127.0.0.1:9200/people/man/

操作说明:people是索引、man是类型、自动产生文档ID而不指定。

{
	"name": "超重瓦力",
	"country": "China",
	"age": 40,
	"date": "1970-08-02"
}

猜你喜欢

转载自rainoo.iteye.com/blog/2396764