Skip to content

Elasticsearch mappings cannot be changed #24363

Closed
@tzyganu

Description

@tzyganu

Summary (*)

Magento 2.3.2
As a developer, I need to develop a custom module that affects the search functionality. This requires extra data to be indexed in elasticsearch. This module requires an extra dynamic template sent to the elasticsearch server in the mappings.

Examples (*)

in version 2.3.2, the mappings are sent via Magento\Elasticsearch6\Model\Client\Elasticsearch::addFieldsMapping (or any other models that can be used as elasticsearch clients depending on elasticsearch version)
And the dynamic templates are hardocded

'dynamic_templates' => [
                        [
                            'price_mapping' => [
                                'match' => 'price_*',
                                'match_mapping_type' => 'string',
                                'mapping' => [
                                    'type' => 'float',
                                    'store' => true,
                                ],
                            ],
                        ],
                        ....

The value cannot be changed via plugins, because the value is sent to elasticsearch as soon as it it built. The method that actually sends the mappings $this->getClient()->indices()->putMapping($params); cannot be pluginized because the object that is being called is not created via Object manager.

Proposed solution

A method that just returns an empty array in the elasticsearch client. The result of this method is merged with the mappings sent to elasticsearch before sending them. This method can be pluginized by third party modules.
This will not break backwards compatibility.

Metadata

Metadata

Assignees

Labels

Component: ElasticsearchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.feature request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions