Elasticsearch 简明教程
Elasticsearch - Populate
在本章中,我们学习了如何在 Elasticsearch 中添加一些索引、映射和数据。请注意,此教程中解释的示例将使用其中一些数据。
In this chapter, let us learn how to add some index, mapping and data to Elasticsearch. Note that some of this data will be used in the examples explained in this tutorial.
Add data
Elasticsearch 将存储我们添加到索引中的文档,如下代码所示。这些文档被赋予一些用于识别文档的 ID。
Elasticsearch will store the documents we add to the index as shown in the following code. The documents are given some IDs which are used in identifying the document.
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
}
在此处,我们正在添加另一个类似文档。
Here, we are adding another similar document.
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"
}
Response
{
"_index" : "school",
"_type" : "_doc",
"_id" : "16",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 9,
"_primary_term" : 7
}
这样,我们将继续添加我们将在即将到来的章节中为工作添加的任何示例数据。
In this way, we will keep adding any example data that we need for our working in the upcoming chapters.
Adding Sample Data in Kibana
Kibana 是一个用于访问数据和创建可视化的 GUI 驱动的工具。在此部分中,我们将了解如何向其中添加示例数据。
Kibana is a GUI driven tool for accessing the data and creating the visualization. In this section, let us understand how we can add sample data to it.
在 Kibana 主页中,选择以下选项以添加示例电子商务数据 -
In the Kibana home page, choose the following option to add sample ecommerce data −

下一个屏幕将显示一些可视化和一个“添加数据”按钮 -
The next screen will show some visualization and a button to Add data −

单击“添加数据”将显示以下屏幕,确认已将数据添加到名为 eCommerce 的索引。
Clicking on Add Data will show the following screen which confirms the data has been added to an index named eCommerce.
