Skip to content

Add support for complex mappings in MappingGenerator#340

Merged
josbeir merged 1 commit into
5.xfrom
mappin_generator_mappings
Nov 15, 2025
Merged

Add support for complex mappings in MappingGenerator#340
josbeir merged 1 commit into
5.xfrom
mappin_generator_mappings

Conversation

@josbeir
Copy link
Copy Markdown
Contributor

@josbeir josbeir commented Nov 8, 2025

Extends MappingGenerator to support full Elasticsearch mapping structures, enabling the use of advanced features like dynamic_templates, dynamic settings, and other mapping-level configurations.

Motivation

Previously, MappingGenerator only supported simple property definitions, automatically wrapping them in a properties key. This prevented users from utilizing advanced Elasticsearch mapping features that need to be defined at the mapping root level, such as dynamic_templates.

Changes

Detection Logic: The method now detects whether the mapping contains a properties key:

  • If present: Treats it as a full mapping structure and uses it as-is
  • If absent: Maintains backward compatibility by wrapping in properties

Example Usage:

// Simple format (backward compatible)
[
    'name' => 'articles',
    'mapping' => [
        'title' => ['type' => 'text'],
        'body' => ['type' => 'text']
    ]
]

// Advanced format (new)
[
    'name' => 'articles',
    'mapping' => [
        'properties' => [
            'title' => ['type' => 'text'],
            'body' => ['type' => 'text']
        ],
        'dynamic_templates' => [
            [
                'strings_as_keywords' => [
                    'match_mapping_type' => 'string',
                    'mapping' => ['type' => 'keyword']
                ]
            ]
        ],
        'dynamic' => 'strict'
    ]
]

@josbeir josbeir requested a review from markstory November 8, 2025 08:39
@josbeir josbeir self-assigned this Nov 8, 2025
@josbeir josbeir force-pushed the 5.x branch 3 times, most recently from 2e15f5e to e6f6a43 Compare November 11, 2025 11:16
@josbeir josbeir merged commit 751bf0b into 5.x Nov 15, 2025
9 checks passed
@josbeir josbeir deleted the mappin_generator_mappings branch November 15, 2025 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant