Skip to content

Recursive index map of index maps #826

Open
@grenik

Description

@grenik

Is there a way to model map of maps?

I see only single-level maps: Property-based data indexing

But maps often have 2+ levels of indexing. Simplified example: animals are indexed by the size, and then by the color.

{
  "@context": {
    "schema": "http://schema.org/",
    "map": {
      "@id": "schema:animals",
      "@type": "@id",
      "@container": "@index",
      "@index": ["schema:size", "schema:color"]
    },
  },
  "map": {
    "small": {
      "green": "schema:Frog",
      "black": "schema:Ant"
    },
    "medium": {
      "black": "schema:Raven"
    },
    "big": {
      "green": "schema:Crocodile"
    }
  }
}

expansion result:

[
  {
    "http://schema.org/animals": [
      {
        "@id": "http://schema.org/Frog",
        "http://schema.org/size": [{"@value": "small"}],
        "http://schema.org/color": [{"@value": "green"}]
      },
      {
        "@id": "http://schema.org/Ant",
        "http://schema.org/size": [{"@value": "small"}],
        "http://schema.org/color": [{"@value": "black"}]
      },
      {
        "@id": "http://schema.org/Raven",
        "http://schema.org/size": [{"@value": "medium"}],
        "http://schema.org/color": [{"@value": "black"}]
      },
      {
        "@id": "http://schema.org/Crocodile",
        "http://schema.org/size": [{"@value": "big"}],
        "http://schema.org/color": [{"@value": "green"}]
      }
    ]
  }
]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions