From 441ff29492051b8867b7b0f7a9b19cc31488fad9 Mon Sep 17 00:00:00 2001 From: dakku Date: Mon, 3 Dec 2018 15:05:51 +0000 Subject: [PATCH 1/9] Issue #3008976 by afi13: Support of Elasticsearch Connector: 8.x-6.x --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 2ee4e7c..9a86d89 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "drupal/search_api_elasticsearch_attachments", - "description": "Search API Elasticsearch Attachments", - "type": "drupal-module", - "minimum-stability": "dev", - "require": { - "drupal/elasticsearch_connector": "5.0-alpha3" - } -} + "name": "drupal/search_api_elasticsearch_attachments", + "description": "Search API Elasticsearch Attachments", + "type": "drupal-module", + "minimum-stability": "dev", + "require": { + "drupal/elasticsearch_connector": "^6.0" + } +} \ No newline at end of file From ae9a58f1b2030929c82a82d79b91aec7e59c5288 Mon Sep 17 00:00:00 2001 From: Alex Goja Date: Tue, 18 Dec 2018 18:41:59 +0200 Subject: [PATCH 2/9] Issue #3020911 by agoja. Adding support for Ingest Attachment Processor Plugin --- composer.json | 2 +- ...api_elasticsearch_attachments.services.yml | 13 +- src/EventSubscriber/BuildIndexParams.php | 188 ++++++++++++++++++ src/EventSubscriber/BuildSearchParams.php | 59 ++++-- src/EventSubscriber/PrepareIndex.php | 30 --- src/EventSubscriber/PrepareIndexMapping.php | 17 +- src/EventSubscriber/PrepareMapping.php | 41 ---- src/EventSubscriber/PrepareQuery.php | 33 --- .../data_type/AttachmentDataType.php | 19 -- .../processor/ElasticsearchAttachments.php | 129 +++++++++--- .../ElasticsearchAttachmentsHighlight.php | 4 +- 11 files changed, 350 insertions(+), 185 deletions(-) create mode 100644 src/EventSubscriber/BuildIndexParams.php delete mode 100644 src/EventSubscriber/PrepareIndex.php delete mode 100644 src/EventSubscriber/PrepareMapping.php delete mode 100644 src/EventSubscriber/PrepareQuery.php delete mode 100644 src/Plugin/search_api/data_type/AttachmentDataType.php diff --git a/composer.json b/composer.json index 9a86d89..f8b3ec7 100644 --- a/composer.json +++ b/composer.json @@ -6,4 +6,4 @@ "require": { "drupal/elasticsearch_connector": "^6.0" } -} \ No newline at end of file +} diff --git a/search_api_elasticsearch_attachments.services.yml b/search_api_elasticsearch_attachments.services.yml index 9f1130e..f00a85f 100644 --- a/search_api_elasticsearch_attachments.services.yml +++ b/search_api_elasticsearch_attachments.services.yml @@ -1,12 +1,4 @@ services: - search_api_elasticsearch_attachments.prepare_index: - class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\PrepareIndex - tags: - - { name: event_subscriber } - search_api_elasticsearch_attachments.prepare_query: - class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\PrepareQuery - tags: - - { name: event_subscriber } search_api_elasticsearch_attachments.prepare_mapping: class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\PrepareMapping tags: @@ -15,7 +7,8 @@ services: class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\BuildSearchParams tags: - { name: event_subscriber } - search_api_elasticsearch_attachments.build_index_mapping: - class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\PrepareIndexMapping + search_api_elasticsearch_attachments.build_index_params: + class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\BuildIndexParams + arguments: ['@elasticsearch_connector.client_manager', '@entity_type.manager'] tags: - { name: event_subscriber } diff --git a/src/EventSubscriber/BuildIndexParams.php b/src/EventSubscriber/BuildIndexParams.php new file mode 100644 index 0000000..c8cbea4 --- /dev/null +++ b/src/EventSubscriber/BuildIndexParams.php @@ -0,0 +1,188 @@ +clientManager = $client_manager; + $this->entityTypeManager = $entity_type_manager; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[BuildIndexParamsEvent::BUILD_PARAMS][] = ['indexParams', 100]; + $events[BuildIndexParamsEvent::BUILD_PARAMS][] = ['pipelineProcessing', 101]; + return $events; + } + + /** + * Method to build Params. + * + * @param \Drupal\elasticsearch_connector\Event\BuildIndexParamsEvent $event + * The BuildIndexParamsEvent event. + */ + public function indexParams(BuildIndexParamsEvent $event) { + // We need to react only on our processor. + $indexName = $this->getIndexName($event); + $processors = $this->getIndexProcessors($indexName); + // Add pipeline param. + if (!empty($processors['elasticsearch_attachments'])) { + $params = $event->getElasticIndexParams(); + // Add pipeline param for attachment processing. + $params['pipeline'] = $this->pipelineName; + // Set updated params array. + $event->setElasticIndexParams($params); + } + } + + /** + * Valdiate pipeline. Create new one or delete existing. + * + * @param \Drupal\elasticsearch_connector\Event\BuildIndexParamsEvent $event + * The BuildIndexParamsEvent event. + */ + public function pipelineProcessing(BuildIndexParamsEvent $event) { + // Get incex name and list of available processors. + $indexName = $this->getIndexName($event); + $processors = $this->getIndexProcessors($indexName); + /** @var \Drupal\search_api\IndexInterface $index */ + $index = $this->getIndex($indexName); + // Initialize client to work with. + $this->initializeClient($index); + // Pipeline registration. + if (!empty($processors['elasticsearch_attachments'])) { + // If there is no pipeline yet, Elastic will return Missing404Exception. + // There is no other way to check if pipeline exist. + try { + $this->getPipeline(); + } + catch (Missing404Exception $e) { + $this->putPipeline(); + } + } + else { + // If there is no pipeline yet, Elastic will return Missing404Exception. + // There is no other way to check if pipeline exist. + try { + $this->getPipeline(); + $this->deletePipeline(); + } + catch (Missing404Exception $e) { + // Nothing to do here. + } + } + } + + /** + * Get index name. + * + * @param \Drupal\elasticsearch_connector\Event\BuildIndexParamsEvent $event + * The BuildIndexParamsEvent event. + * + * @return string + * Index name + */ + public function getIndexName(BuildIndexParamsEvent $event) { + return Helpers::getIndexName($event->getIndexName()); + } + + /** + * Get list of all available index processors. + * + * @param string $indexName + * Name of index. + * + * @return array + * List of all available processors. + */ + public function getIndexProcessors($indexName) { + return Index::load($indexName)->getProcessors(); + } + + /** + * Get list of all available index processors. + * + * @param string $indexName + * Name of index. + * + * @return \Drupal\search_api\IndexInterface + * Index object. + */ + public function getIndex($indexName) { + return Index::load($indexName); + } + + /** + * ElasticSearch client initialization. + * + * @param \Drupal\search_api\IndexInterface $index + * The index scheduled for indexing. + */ + public function initializeClient(IndexInterface $index) { + $cluster_name = $index->getServerInstance()->getBackend()->getCluster(); + $cluster = $this->entityTypeManager->getStorage('elasticsearch_cluster')->load($cluster_name); + $this->client = $this->clientManager->getClientForCluster($cluster); + } + + /** + * Helper to register new pipeline. + */ + public function putPipeline() { + $params = []; + $params['id'] = $this->pipelineName; + $params['body'] = [ + 'description' => 'Extract attachment information from arrays', + 'processors' => [ + [ + 'foreach' => [ + 'field' => $this->targetFieldId, + 'ignore_failure' => TRUE, + 'processor' => [ + 'attachment' => [ + 'target_field' => '_ingest._value.attachment', + 'field' => '_ingest._value.data', + ], + ], + ], + ], + ], + ]; + $this->client->ingest()->putPipeline($params); + } + + /** + * Helper to delete exiting pipeline. + */ + public function deletePipeline() { + $this->client->ingest()->deletePipeline(['id' => $this->pipelineName]); + } + + /** + * Helper to get exiting pipeline. + */ + public function getPipeline() { + return $this->client->ingest()->getPipeline(['id' => $this->pipelineName]); + } + +} diff --git a/src/EventSubscriber/BuildSearchParams.php b/src/EventSubscriber/BuildSearchParams.php index f25c037..7a3256b 100644 --- a/src/EventSubscriber/BuildSearchParams.php +++ b/src/EventSubscriber/BuildSearchParams.php @@ -28,26 +28,59 @@ public static function getSubscribedEvents() { */ public function searchParams(BuildSearchParamsEvent $event) { $params = $event->getElasticSearchParams(); - - // Default Prefix and Suffix. - $prefix = ''; - $suffix = ''; - - // We need to get the Prefix and Suffix from processor. + // Seet default boost. + $boost = 1.0; + // We need to get the processor. $indexName = Helpers::getIndexName($event->getIndexName()); $processors = Index::load($indexName)->getProcessors(); - + // Try to load boost value from config form. + if (!empty($processors['elasticsearch_attachments'])) { + $boost = $processors['elasticsearch_attachments']->getConfiguration()['boost']; + // Get original query. + $originalBoolQuery = $params['body']['query']['bool']['must']; + // Get query string. + if (isset($originalBoolQuery['query_string'])) { + $queryString = $originalBoolQuery['query_string']['query']; + // Build nestedQuery. + // @see https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-query.html. + $nestedQuery = [ + 'nested' => [ + 'path' => 'es_attachment', + 'query' => [ + 'bool' => [ + 'must' => [ + 'query_string' => [ + 'query' => $queryString, + 'fields' => [ + 'es_attachment.attachment.content^' . $boost, + ], + ], + ], + ], + ], + ], + ]; + // We need to change the bool query from must to should. + // This is requried to add support for nested and string queries. + $params['body']['query']['bool']['should'] = []; + unset($params['body']['query']['bool']['must']); + $params['body']['query']['bool']['should'][] = $originalBoolQuery; + $params['body']['query']['bool']['should'][] = $nestedQuery; + // Add min match param. + $params['body']['query']['bool']['minimum_should_match'] = 1; + } + } + // Add highlight if enabled. if (!empty($processors['elasticsearch_attachments_highlight'])) { $processorConf = $processors['elasticsearch_attachments_highlight']->getConfiguration(); $prefix = $processorConf['prefix']; $suffix = $processorConf['suffix']; + // See: https://github.com/elastic/elasticsearch-php/issues/394 + $params['body']['highlight']['fields']['es_attachment.attachment.content'] = (object) []; + $params['body']['highlight']['pre_tags'] = [$prefix]; + $params['body']['highlight']['post_tags'] = [$suffix]; } - - // See: https://github.com/elastic/elasticsearch-php/issues/394 - $params['body']['highlight']['fields']['es_attachment.content'] = (object) []; - $params['body']['highlight']['pre_tags'] = [$prefix]; - $params['body']['highlight']['post_tags'] = [$suffix]; - + // Set updated params array. $event->setElasticSearchParams($params); } diff --git a/src/EventSubscriber/PrepareIndex.php b/src/EventSubscriber/PrepareIndex.php deleted file mode 100644 index 9f903ea..0000000 --- a/src/EventSubscriber/PrepareIndex.php +++ /dev/null @@ -1,30 +0,0 @@ -getIndexMappingParams(); - // Exclude our source field from getting saved in ES. - // See: https://qbox.io/blog/index-attachments-files-elasticsearch-mapper - $indexMappingParams['body'][$indexMappingParams['type']]['_source']['excludes'][] = 'es_attachment'; - $event->setIndexMappingParams($indexMappingParams); + // We need to react only on our processor. + $indexName = Helpers::getIndexName($event->getIndexName()); + $processors = Index::load($indexName)->getProcessors(); + // Exclude field only if processor is enabled. + if (!empty($processors['elasticsearch_attachments'])) { + $indexMappingParams = $event->getIndexMappingParams(); + // Exclude our source encoded data field from getting saved in ES. + $indexMappingParams['body'][$indexMappingParams['type']]['_source']['excludes'][] = 'es_attachment.data'; + $event->setIndexMappingParams($indexMappingParams); + } } } diff --git a/src/EventSubscriber/PrepareMapping.php b/src/EventSubscriber/PrepareMapping.php deleted file mode 100644 index 8f7c163..0000000 --- a/src/EventSubscriber/PrepareMapping.php +++ /dev/null @@ -1,41 +0,0 @@ -getMappingConfig(); - $type = $event->getMappingType(); - if ($type == 'attachment') { - $mappingConfig['fields'] = [ - "content" => [ - "store" => TRUE, - "term_vector" => "with_positions_offsets", - ], - ]; - $event->setMappingConfig($mappingConfig); - } - } - -} diff --git a/src/EventSubscriber/PrepareQuery.php b/src/EventSubscriber/PrepareQuery.php deleted file mode 100644 index 7ba0829..0000000 --- a/src/EventSubscriber/PrepareQuery.php +++ /dev/null @@ -1,33 +0,0 @@ -getElasticSearchQuery(); - $elasticSearchQuery['query_search_string']['query_string']['fields'][] = 'es_attachment.content'; - $event->setElasticSearchQuery($elasticSearchQuery); - } - -} diff --git a/src/Plugin/search_api/data_type/AttachmentDataType.php b/src/Plugin/search_api/data_type/AttachmentDataType.php deleted file mode 100644 index 1a99f66..0000000 --- a/src/Plugin/search_api/data_type/AttachmentDataType.php +++ /dev/null @@ -1,19 +0,0 @@ - '0.0', + '0.1' => '0.1', + '0.2' => '0.2', + '0.3' => '0.3', + '0.5' => '0.5', + '0.8' => '0.8', + '1.0' => '1.0', + '2.0' => '2.0', + '3.0' => '3.0', + '5.0' => '5.0', + '8.0' => '8.0', + '13.0' => '13.0', + '21.0' => '21.0', + ]; /** * The mime type guesser service. @@ -62,12 +105,7 @@ class ElasticsearchAttachments extends ProcessorPluginBase implements PluginForm /** * {@inheritdoc} */ - public function __construct(array $configuration, - $plugin_id, - array $plugin_definition, - MimeTypeGuesserInterface $mime_type_guesser, - ConfigFactoryInterface $config_factory, - KeyValueFactoryInterface $key_value) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, MimeTypeGuesserInterface $mime_type_guesser, ConfigFactoryInterface $config_factory, KeyValueFactoryInterface $key_value) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->mimeTypeGuesser = $mime_type_guesser; @@ -78,10 +116,7 @@ public function __construct(array $configuration, /** * {@inheritdoc} */ - public static function create(ContainerInterface $container, - array $configuration, - $plugin_id, - $plugin_definition) { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static($configuration, $plugin_id, $plugin_definition, @@ -125,7 +160,11 @@ private function indexFile(ItemInterface $item, File $file) { if ($this->isFileIndexable($file)) { $extraction = $this->extractOrGetFromCache($file); $targetField = $item->getFields()[$this->targetFieldId]; - $targetField->addValue($extraction); + $fileData = [ + 'filename' => $file->get('filename')->value, + 'data' => $extraction, + ]; + $targetField->addValue($fileData); } } @@ -134,32 +173,53 @@ private function indexFile(ItemInterface $item, File $file) { */ public function addFieldValues(ItemInterface $item) { $entity_type = $item->getDatasource()->getEntityTypeId(); - if ($entity_type == 'file') { + if (in_array($entity_type, static::$supportedNodeFieldTypes)) { $this->indexFile($item, $item->getOriginalObject()->getValue()); } elseif ($entity_type == 'node') { - // Find all the file fields that were selected for indexing. - $indexed_fields = []; - foreach ($item->getFields() as $field) { + $entity = $item->getOriginalObject()->getValue(); + foreach ($entity->getFields() as $field) { $data_definition = $field->getDataDefinition(); - if (get_class($data_definition) !== 'Drupal\Core\Field\TypedData\FieldItemDataDefinition') { + if (get_class($data_definition) !== 'Drupal\field\Entity\FieldConfig') { continue; } - if ($data_definition->getFieldDefinition()->getType() !== 'file') { + $storage = $data_definition->getFieldStorageDefinition(); + // Check the field for type and process indexation. + if ( + in_array($storage->getType(), static::$supportedNodeFieldTypes) + && !empty($files = $field->referencedEntities()) + ) { + foreach ($files as $file) { + $this->indexFile($item, $file); + } continue; } - $indexed_fields[] = $field->getPropertyPath(); - } - - // Attempt to index each file in each file field. - $node = $item->getOriginalObject()->getValue(); - foreach ($indexed_fields as $indexed_field) { - if (!$node->hasField($indexed_field)) { + // Check the entity reference fields and extract attachments data. + if ($storage instanceof FieldStorageConfigInterface && $storage->getType() !== 'entity_reference') { continue; } - $file_field = $node->get($indexed_field); - foreach ($file_field as $file_item) { - $this->indexFile($item, $file_item->view()['#file']); + if (!isset($storage->getSettings()['target_type']) || $storage->getSettings()['target_type'] !== 'media') { + continue; + } + + if ($field->referencedEntities()) { + foreach ($field->referencedEntities() as $field_value) { + foreach ($field_value->getFields() as $child_field) { + $data_definition = $child_field->getDataDefinition(); + if (get_class($data_definition) !== 'Drupal\field\Entity\FieldConfig') { + continue; + } + $storage = $data_definition->getFieldStorageDefinition(); + if ( + in_array($storage->getType(), static::$supportedNodeFieldTypes) + && !empty($files = $child_field->referencedEntities()) + ) { + foreach ($files as $file) { + $this->indexFile($item, $file); + } + } + } + } } } } @@ -171,7 +231,6 @@ public function addFieldValues(ItemInterface $item) { public function preIndexSave() { // Automatically add field to index if processor is enabled. $field = $this->ensureField(NULL, $this->targetFieldId, $this->targetFieldType); - // Hide the field. $field->setHidden(); } @@ -187,6 +246,13 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $defaultExcludedExtensions = $this->defaultExcludedExtensions(); } + $form['boost'] = [ + '#type' => 'select', + '#title' => $this->t('Default boost for attachments'), + '#options' => static::$boostFactors, + '#default_value' => sprintf('%.1f', isset($this->configuration['boost']) ? $this->configuration['boost'] : 1.0), + ]; + $form['excluded_extensions'] = [ '#type' => 'textfield', '#title' => $this->t('Excluded file extensions'), @@ -272,7 +338,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s * string of file extensions separated by a space. */ public function defaultExcludedExtensions() { - return 'aif art avi bmp gif ico mov oga ogv png psd ra ram rgb flv'; + return 'aif art avi bmp gif ico mov oga ogv png psd ra ram rgb flv jpg jpeg'; } /** @@ -403,7 +469,8 @@ public function extractOrGetFromCache($file) { // Extract. $extractedData = $this->extract($file); // Set cache. - $this->keyValue->get($collection)->set($key, $extractedData); + // @TODO: Large files cause innodb_log_file_size fatal error. + // $this->keyValue->get($collection)->set($key, $extractedData). } return $extractedData; diff --git a/src/Plugin/search_api/processor/ElasticsearchAttachmentsHighlight.php b/src/Plugin/search_api/processor/ElasticsearchAttachmentsHighlight.php index d995b7f..47c3561 100644 --- a/src/Plugin/search_api/processor/ElasticsearchAttachmentsHighlight.php +++ b/src/Plugin/search_api/processor/ElasticsearchAttachmentsHighlight.php @@ -118,8 +118,8 @@ protected function addExcerpts(array $results, array $elasticsearchResponse) { $itemId = $item['_id']; $highlightsString = ''; - if (isset($item['highlight']) && isset($item['highlight']['es_attachment.content'])) { - $highlights = $item['highlight']['es_attachment.content']; + if (isset($item['highlight']) && isset($item['highlight']['es_attachment.attachment.content'])) { + $highlights = $item['highlight']['es_attachment.attachment.content']; // There can be multiple highlights. foreach ($highlights as $highlight) { $highlightsString .= $highlight; From b87008cfea8256eba1f8dc8a17a8e62b22be5e8e Mon Sep 17 00:00:00 2001 From: Alex Goja Date: Tue, 18 Dec 2018 18:46:43 +0200 Subject: [PATCH 3/9] Issue #3020911 by agoja. README.md update --- README.md | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 947364a..b678d3d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Search API Elasticsearch Attachments [![CircleCI](https://circleci.com/gh/dakkusingh/search_api_elasticsearch_attachments.svg?style=svg)](https://circleci.com/gh/dakkusingh/search_api_elasticsearch_attachments) -Elasticsearch is generally used to index data of types like string, -number, date, etc. -However, what if you wanted to index a file like a .pdf or a .doc +Elasticsearch is generally used to index data of types like string, +number, date, etc. +However, what if you wanted to index a file like a .pdf or a .doc directly and make it searchable? -This module allows Drupal to index files (attachments) to Elasticsearch by +This module allows Drupal to index files (attachments) to Elasticsearch by making use of Elasticsearch data type "attachment". ![Search_API_Elasticsearch_Attachments](https://www.drupal.org/files/search_api_elasticsearch_attachments.jpg) @@ -15,18 +15,18 @@ making use of Elasticsearch data type "attachment". This module requires: * Drupal 8 * Search API Module -* Elasticsearch Connector module (Alpha 2) +* Elasticsearch Connector module (Alpha 1) * Elasticsearch Version 5.6 -* Elasticsearch `mapper-attachments` plugin +* Elasticsearch `ingest-attachment` plugin ## Elasticsearch Plugin Installation -The first step is to install the Elasticsearch plugin: `mapper-attachments`, -which enables ES to recognise the "attachment" data type. In turn, it uses -Apache Tika for content extraction and supports several file types such as +The first step is to install the Elasticsearch plugin: `ingest-attachment`, +which enables ES to recognise the "attachment" data type. In turn, it uses +Apache Tika for content extraction and supports several file types such as .pdf, .doc, .xls, .rtf, .html, .odt, etc. ``` -$ES_HOME> bin/elasticsearch-plugin install mapper-attachments +$ES_HOME> bin/elasticsearch-plugin install ingest-attachment ``` Thats the hard work done. @@ -36,25 +36,18 @@ composer require drupal/search_api_elasticsearch_attachments ``` ## Elasticsearch Connector module (Alpha 1) compatibility. -Alpha 1 version of Elasticsearch Connector module requires a number of patches. -If you are using Alpha 1, please use 8.x-1.0-alpha1 of +Alpha 1 version of Elasticsearch Connector module requires a number of patches. +If you are using Alpha 1, please use 8.x-6.0-alpha1 of *search_api_elasticsearch_attachments* module. -This will auto install the *search_api_elasticsearch_attachments* module +This will auto install the *search_api_elasticsearch_attachments* module and also install the *elasticsearch_connector* module -There are a number of patches required to elasticsearch_connector module -(Alpha 1 only). These are applied automatically by composer. -Sit back and let composer do the hard work for you. Patches that will +There are a number of patches required to elasticsearch_connector module +(Alpha 1 only). These are applied automatically by composer. +Sit back and let composer do the hard work for you. Patches that will get auto applied by composer: -* Issue #2926853 by dakku: Allow hook for altering getSearchQueryOptions -* Issue #2927465 by dakku: Allow option for altering IndexFactory Settings -& Options -* Issue #2930819 by dakku: Allow option for altering MappingFactory Options -* Issue #2932003 by dakku: Allow option for altering -SearchBuilder:build $params -* Issue #2932301 by dakku: Allow option for altering -IndexFactory:mapping $params +* Issue #2918138 by dakku: Support for alterParams() ## Elasticsearch Attachments Configuration ### Enable and Configure the Elasticsearch Attachments Processor From 72f48cbe2bda1f107f77bc67df918853eb5662e8 Mon Sep 17 00:00:00 2001 From: Alex Goja Date: Tue, 18 Dec 2018 18:49:25 +0200 Subject: [PATCH 4/9] Issue #3020911 by agoja. README.md update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b678d3d..4fa5513 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This module requires: * Drupal 8 * Search API Module * Elasticsearch Connector module (Alpha 1) -* Elasticsearch Version 5.6 +* Elasticsearch Version 6.2 * Elasticsearch `ingest-attachment` plugin ## Elasticsearch Plugin Installation From 6f2df4e9d8c98a72184105512362e9fe3939fa62 Mon Sep 17 00:00:00 2001 From: Alex Goja Date: Tue, 18 Dec 2018 19:25:24 +0200 Subject: [PATCH 5/9] Issue #3020911 Fix service naming --- search_api_elasticsearch_attachments.services.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/search_api_elasticsearch_attachments.services.yml b/search_api_elasticsearch_attachments.services.yml index f00a85f..9d2cd10 100644 --- a/search_api_elasticsearch_attachments.services.yml +++ b/search_api_elasticsearch_attachments.services.yml @@ -1,12 +1,12 @@ services: - search_api_elasticsearch_attachments.prepare_mapping: - class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\PrepareMapping - tags: - - { name: event_subscriber } search_api_elasticsearch_attachments.build_query: class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\BuildSearchParams tags: - { name: event_subscriber } + search_api_elasticsearch_attachments.build_index_mapping: + class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\PrepareIndexMapping + tags: + - { name: event_subscriber } search_api_elasticsearch_attachments.build_index_params: class: Drupal\search_api_elasticsearch_attachments\EventSubscriber\BuildIndexParams arguments: ['@elasticsearch_connector.client_manager', '@entity_type.manager'] From 96668092603dcbf02b925deeaaa9cd881d034461 Mon Sep 17 00:00:00 2001 From: Alex Goja Date: Tue, 18 Dec 2018 19:51:48 +0200 Subject: [PATCH 6/9] Issue #3020911 by agoja: Fix typo --- src/EventSubscriber/BuildSearchParams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EventSubscriber/BuildSearchParams.php b/src/EventSubscriber/BuildSearchParams.php index 7a3256b..8f45d5e 100644 --- a/src/EventSubscriber/BuildSearchParams.php +++ b/src/EventSubscriber/BuildSearchParams.php @@ -28,7 +28,7 @@ public static function getSubscribedEvents() { */ public function searchParams(BuildSearchParamsEvent $event) { $params = $event->getElasticSearchParams(); - // Seet default boost. + // Set default boost. $boost = 1.0; // We need to get the processor. $indexName = Helpers::getIndexName($event->getIndexName()); From 6bd269f11c8fb06e2b62c57df9fe13c3e8e5da03 Mon Sep 17 00:00:00 2001 From: Alex Goja Date: Wed, 19 Dec 2018 12:17:18 +0200 Subject: [PATCH 7/9] Issue #3020911 by agoja: Added ES connector patch in composer.json --- composer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composer.json b/composer.json index f8b3ec7..5d474ed 100644 --- a/composer.json +++ b/composer.json @@ -5,5 +5,12 @@ "minimum-stability": "dev", "require": { "drupal/elasticsearch_connector": "^6.0" + }, + "extra": { + "patches": { + "drupal/elasticsearch_connector": { + "Issue #2918138": "https://www.drupal.org/files/issues/2018-12-14/elasticsearch_connector-alter_params-2918138-5.patch" + } + } } } From b28eb2b3260d806cc3dbda50562763cad433547a Mon Sep 17 00:00:00 2001 From: Alex Goja Date: Wed, 19 Dec 2018 14:39:44 +0200 Subject: [PATCH 8/9] Issue #3020911 by agoja: Update composer.json for 5.x version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d474ed..9b68bac 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "drupal-module", "minimum-stability": "dev", "require": { - "drupal/elasticsearch_connector": "^6.0" + "drupal/elasticsearch_connector": "5.0-alpha3" }, "extra": { "patches": { From 6b342553adcebb6b8f3dc39de856f0ac2a318613 Mon Sep 17 00:00:00 2001 From: Alex Goja Date: Wed, 19 Dec 2018 14:44:29 +0200 Subject: [PATCH 9/9] Issue #3020911 by agoja: Update README for 5.x version --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4fa5513..738d692 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ making use of Elasticsearch data type "attachment". This module requires: * Drupal 8 * Search API Module -* Elasticsearch Connector module (Alpha 1) -* Elasticsearch Version 6.2 +* Elasticsearch Connector module (8.x-5.x) +* Elasticsearch Version 5.6 * Elasticsearch `ingest-attachment` plugin ## Elasticsearch Plugin Installation @@ -35,16 +35,16 @@ Thats the hard work done. composer require drupal/search_api_elasticsearch_attachments ``` -## Elasticsearch Connector module (Alpha 1) compatibility. -Alpha 1 version of Elasticsearch Connector module requires a number of patches. -If you are using Alpha 1, please use 8.x-6.0-alpha1 of +## Elasticsearch Connector module (5.x) compatibility. +8.x-5.0-alpha3 version of Elasticsearch Connector module requires a number of patches. +If you are using 5.x, please use 8.x-5.x-dev of *search_api_elasticsearch_attachments* module. This will auto install the *search_api_elasticsearch_attachments* module and also install the *elasticsearch_connector* module -There are a number of patches required to elasticsearch_connector module -(Alpha 1 only). These are applied automatically by composer. +There are a number of patches required to elasticsearch_connector module. +These are applied automatically by composer. Sit back and let composer do the hard work for you. Patches that will get auto applied by composer: * Issue #2918138 by dakku: Support for alterParams()