嵌套-映射

嵌套对象映射

设定一个nested栏位很简单—在你会设定为object类型的地方,改为nested类型:

  1. PUT /my_index
  2. {
  3. "mappings": {
  4. "blogpost": {
  5. "properties": {
  6. "comments": {
  7. "type": "nested", <1>
  8. "properties": {
  9. "name": { "type": "string" },
  10. "comment": { "type": "string" },
  11. "age": { "type": "short" },
  12. "stars": { "type": "short" },
  13. "date": { "type": "date" }
  14. }
  15. }
  16. }
  17. }
  18. }
  19. }

<1> 一个nested栏位接受与object类型相同的参数。

所需仅此而已。 任何comments对象会被索引为分离嵌套对象。
参考更多 nested type reference docs