Elasticsearch 7.0 Cookbook(Fourth Edition)
上QQ阅读APP看书,第一时间看更新

How to do it...

Let's use a semi real-world example of a shop order for our eBay-like shop:

  1. First, we define an order:
  1. Our order record must be converted into an Elasticsearch mapping definition as follows:
PUT test/_mapping
{
"properties" : {
"id" : {"type" : "keyword"},
"date" : {"type" : "date"},
"customer_id" : {"type" : "keyword"},
"sent" : {"type" : "boolean"},
"name" : {"type" : "keyword"},
"quantity" : {"type" : "integer"},
"price" : {"type" : "double"},
"vat" : {"type" : "double", "index":"false"}
}
}

Now, the mapping is ready to be put in the index. We will see how to do this in the Putting a Mapping in an Index recipe in Chapter 4, Basic Operations.