Elasticsearch 简明教程
Elasticsearch - Populate
在本章中,我们学习了如何在 Elasticsearch 中添加一些索引、映射和数据。请注意,此教程中解释的示例将使用其中一些数据。
Add data
Elasticsearch 将存储我们添加到索引中的文档,如下代码所示。这些文档被赋予一些用于识别文档的 ID。
Request Body
POST school/_doc/10
{
"name":"Saint Paul School", "description":"ICSE Afiliation",
"street":"Dawarka", "city":"Delhi", "state":"Delhi", "zip":"110075",
"location":[28.5733056, 77.0122136], "fees":5000,
"tags":["Good Faculty", "Great Sports"], "rating":"4.5"
}
Response
{
"_index" : "school",
"_type" : "_doc",
"_id" : "10",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 2,
"_primary_term" : 1
}
在此处,我们正在添加另一个类似文档。
POST school/_doc/16
{
"name":"Crescent School", "description":"State Board Affiliation",
"street":"Tonk Road",
"city":"Jaipur", "state":"RJ", "zip":"176114","location":[26.8535922,75.7923988],
"fees":2500, "tags":["Well equipped labs"], "rating":"4.5"
}