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

How to do it...

A nested object is defined as the standard object with the nested type.

From the example in the Mapping an object recipe, we can change the type from object to nested as follows:

PUT test/_mapping
{
"properties" : {
"id" : {"type" : "keyword"},
"date" : {"type" : "date"},
"customer_id" : {"type" : "keyword"},
"sent" : {"type" : "boolean"},
"item" : {"type" : "nested",
"properties" : {
"name" : {"type" : "keyword"},
"quantity" : {"type" : "long"},
"price" : {"type" : "double"},
"vat" : {"type" : "double"}
}
}
}
}