假设我正在为Elasticsearch索引一堆产品可用的Products和Stores.例如,文档看起来像:
{
name: "iPhone 6s",
price: 600.0,
stores: [
{
name: "Apple Store Union Square",
location: "San Francisco, CA"
},
{
name: "Target Cupertino",
location: "Cupertino, CA"
},
{
name: "Apple Store 5th Avenue",
location: "New York, NY"
}
...
]
}
Run Code Online (Sandbox Code Playgroud)
并使用该nested类型,映射将是:
"mappings" : {
"product" : {
"properties" : {
"name" : {
"type" : "string"
},
"price" : {
"type" : "float"
},
"stores" : {
"type" : "nested",
"properties" : …Run Code Online (Sandbox Code Playgroud)