Skip to content

Add a way to store unstructured none filterable, none searchable, none distinctable Metadata #614

@alexander-schranz

Description

@alexander-schranz

Sometimes you require additional data to your document which you require for your view, but don't match a strict schema which we enforce in SEAL.

In Sulu for example we have requirement to store routeAttributes to a document:

Example Page:

{
    "id": "pages::1::en",
    "title": "Some Page",
    "resourceKey": "pages",
    "resourceId": "1",
    "locale": "en",

    "routeAttributes": {
        "webspace": "extranet"
    }
}

Example Article:

{
    "id": "pages::1::en",
    "title": "Some Page",
    "resourceKey": "pages",
    "resourceId": "1",
    "locale": "en",

    "routeAttributes": {
        "group": "blog"
    }
}

So the route attributes are some kind of unstructured data. They are never searchable, never filterable, never array<string, mixed>.

A few Engines already support ignoring additional data and just store them. Other engines have some kind of "auto" detection which we may can workaround by using a JSON Text field and store it this way:

{
    "id": "pages::1::en",
    "title": "Some Page",
    "resourceKey": "pages",
    "resourceId": "1",
    "locale": "en",

    "routeAttributes": "{\"group\": \"blog\"}"
}

I'm not yet sure how to handle this I think I would add a new field type:

use CmsIg\Seal\Schema\Field;
use CmsIg\Seal\Schema\Index;

return new Index('admin', [
    'id' => new Field\IdentifierField('id'),
    'resourceKey' => new Field\TextField('resourceKey', searchable: false, filterable: true),
    'resourceId' => new Field\TextField('resourceId', searchable: false),
    'locale' => new Field\TextField('locale', searchable: false, filterable: true),
    'title' => new Field\TextField('title'),
    'mediaId' => new Field\IntegerField('mediaId'),
    'changedAt' => new Field\DateTimeField('changedAt'),
    'createdAt' => new Field\DateTimeField('createdAt'),

    'routeAttributes' => new Field\UnstructuredField(),
]);

What do you think @Toflar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SEAL CoreSeal Core related issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions