It would be nice to allow other modules to change the mapping before it is sent to the elastic server during setup.

The patch is attached for elasticsearch_helper_content submodule.

Comments

a.dmitriiev created an issue. See original summary.

a.dmitriiev’s picture

StatusFileSize
new2.7 KB
a.dmitriiev’s picture

Status: Active » Needs review
a.dmitriiev’s picture

Unfortunately there is no version of the module that supports ElasticSearch version 7, that is why I am attaching the updated patch here. Remember to update "elasticsearch/elasticsearch" library to version 7 too, this could be done by adding this line to your root composer "elasticsearch/elasticsearch": "7.6.1 as 6.9.99" require section or just running the command:

composer require elasticsearch/elasticsearch:"7.6.1 as 6.9.99"

For the ones who are interested - here is the list of breaking changes in elastic 7 https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking... .

The patch covers a tiny part: creating of the indexes, putting Mapping and index content.

a.dmitriiev’s picture

StatusFileSize
new4.83 KB

Forgot to change the version in composer.json

a.dmitriiev’s picture

Updated patch for ES7, there are more places were type of mapping is used, but it is not needed anymore in ES7

jcnventura’s picture

Re-roll of the patch for those testing in conjunction with #3113356: Drupal 9 readiness

maijs’s picture

Version: 8.x-6.x-dev » 8.x-dev
StatusFileSize
new12.4 KB

The object oriented approach to index mapping has been introduced in version 7, and since then the best way to alter the data prior to an Elasticsearch operation was to use an event listener.

The patch attached allows event listeners to receive the index name and the index definition instance (incl. the mapping definition), and alter the existing mapping or add a new field.

The patch also includes an example event listener included in the elasticsearch_helper_example module.

  • maijs committed 0c1502dd on 8.x
    Issue #3059128 by a.dmitriiev, jcnventura, maijs: Allow altering the...
maijs’s picture

Status: Needs review » Fixed
maijs’s picture

Event listeners now can access and modify the index_definition object when an index is created. This allows custom modules to modify the index settings and the mapping.

See an example in the elasticsearch_helper_example module - https://git.drupalcode.org/project/elasticsearch_helper/-/blob/8.x/examp...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.