Need help adding analyzer mappings to the index when it is being created

Created on 9 September 2016, over 8 years ago
Updated 24 September 2024, 3 months ago

I'm trying to add some logic to a custom module for index time. I'd like to add analyzer mappings, etc to the index when it is being created.

I've tracked down the place that's happening here in the create() method:

modules\contrib\elasticsearch_connector\src\ElasticSearch\Parameters\Factory\IndexFactory.php

I have a custom module that I'm trying to extend that method and add to it but can't seem to get it to fire. So far my folder structure for my custom module looks like this:

modules\custom\elasticsearch_analyzer\src\elasticsearch_analyzer.php

<?php

namespace Drupal\elasticsearch_analyzer;

use Drupal\search_api\IndexInterface;
use Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory;

class elasticsearch_analyzer extends IndexFactory {

  /**
   * {@inheritdoc}
   */
  public static function create(IndexInterface $index) {
    die('does this work?');
    return [
      'index' => IndexFactory::getIndexName($index),
      'body' => [
        'settings' => [
          'number_of_shards' => $index->getOption('number_of_shards', 5),
          'number_of_replicas' => $index->getOption('number_of_replicas', 1),
        ],
      ],
    ];
  }

}

I've tried a bunch of different combinations surrounding the PSR-4 standard, but can't seem to get it to run. Is this how we'd normally go about extending things in Drupal 8?

💬 Support request
Status

Postponed: needs info

Version

7.0

Component

Code

Created by

🇨🇦Canada rferguson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada mparker17 UTC-4

    The 8.x-2.x version of elasticsearch_connector is no longer supported; but this class is still present in the 8.x-7.x-dev branch (which is supported).

    In the 8.x-7.x version of the module, the \Drupal\elasticsearch_connector\Event\PrepareIndexEvent allows you to alter the index configuration before it is created.

    In the 8.0.x version of the module, the \Drupal\elasticsearch_connector\Event\AlterSettingsEvent event is dispatched before creating the index; and the \Drupal\elasticsearch_connector\Event\IndexCreatedEvent event is dispatched shortly after the index is created.

    @rferguson, does this help you to accomplish what you are hoping?

    (I am cleaning up old issues as part of a big review of open issues for 🌱 [Meta] Roadmap for a stable release with security coverage Active : thank you for your patience with me)

Production build 0.71.5 2024