ElasticSearch Introductory Course Example

First, create an index operation

Operation Type: PUT

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

 

2. Insert data operation

1)

Operation Type: PUT

Operation address: http://127.0.0.1:9200/people/man/1

Operation instructions: people is the index, man is the type, and 1 is the specified document ID.

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

 

2)

Action Type: POST

Operation address: http://127.0.0.1:9200/people/man/

Operation instructions: people is the index, man is the type, and the document ID is automatically generated without specifying it.

{
	"name": "Overweight Wall-E",
	"country": "China",
	"age": 40,
	"date": "1970-08-02"
}

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326198410&siteId=291194637