
上QQ阅读APP看书,第一时间看更新
Mappings
To understand mappings, let's add another product to the product catalog:
PUT /catalog/_doc/2
{
"sku": "SP000002",
"title": "Google Pixel Phone 32GB - 5 inch display",
"description": "Google Pixel Phone 32GB - 5 inch display (Factory Unlocked US Version)",
"price": 400.00,
"resolution": "1440 x 2560 pixels",
"os": "Android 7.1"
}
Copy and paste this example into the editor of your Kibana Console UI and execute it.
As you can see, the product has many different fields, as it is of a completely different category. Yet, there are some fields that are common in all products. The common fields are the reason why all of these documents are called products.
Remember, unlike relational databases, we didn't have to define the fields that would be part of each document. In fact, we didn't even have to create an index with the name catalog. When the first document about the product type was indexed in the index catalog, the following tasks were performed by Elasticsearch:
- Creating an index with the name catalog
- Defining the mappings for the type of documents that will be stored in the index's default type – _doc