From e8fd6104fa75a5a36099d1e54475dc2c661c1adb Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 19 Aug 2020 20:55:29 +0300 Subject: [PATCH 1/2] [CR-22] Update search_api_solr --- composer.json | 2 +- .../optional/search_api.index.default.yml | 74 +++++++++++++++---- .../optional/search_api.server.solr.yml | 22 ++++-- .../install/search_api.server.solr_search.yml | 25 +++++-- .../openy_search_api/openy_search_api.install | 32 ++++++++ openy.profile | 40 ++++++++++ src/Form/SearchSolrForm.php | 2 +- 7 files changed, 170 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index ad85f2ec6a..a9a2996c6b 100644 --- a/composer.json +++ b/composer.json @@ -283,7 +283,7 @@ "drupal/social_feed_fetcher": "^2.0", "symfony/dom-crawler": "~2.8|~3.0|~4.2", "mpdf/mpdf": "^7.1", - "drupal/search_api_solr": "1.3", + "drupal/search_api_solr": "^4.1", "drupal/search_api": "1.17", "npm-asset/blazy": "^1.8", "npm-asset/slick-carousel": "^1.8", diff --git a/modules/custom/openy_activity_finder/config/optional/search_api.index.default.yml b/modules/custom/openy_activity_finder/config/optional/search_api.index.default.yml index 4bcad1bd1a..08572864f9 100644 --- a/modules/custom/openy_activity_finder/config/optional/search_api.index.default.yml +++ b/modules/custom/openy_activity_finder/config/optional/search_api.index.default.yml @@ -2,23 +2,62 @@ langcode: en status: true dependencies: config: - - field.storage.node.field_session_min_age - - field.storage.node.field_session_max_age - - field.storage.node.field_session_class - - field.storage.node.field_class_activity - field.storage.node.field_activity_category - - field.storage.node.field_session_location - field.storage.node.field_category_program - - field.storage.node.field_session_time - - field.storage.paragraph.field_session_time_days + - field.storage.node.field_class_activity + - field.storage.node.field_session_class + - field.storage.node.field_session_location + - field.storage.node.field_session_max_age - field.storage.node.field_session_mbr_price + - field.storage.node.field_session_min_age - field.storage.node.field_session_nmbr_price + - field.storage.node.field_session_time - field.storage.paragraph.field_session_time_date + - field.storage.paragraph.field_session_time_days - search_api.server.solr module: + - search_api_solr - node - paragraphs - search_api +third_party_settings: + search_api_solr: + finalize: false + commit_before_finalize: false + commit_after_finalize: false + multilingual: + limit_to_content_language: false + include_language_independent: true + highlighter: + maxAnalyzedChars: 51200 + fragmenter: gap + regex: + slop: 0.5 + pattern: blank + maxAnalyzedChars: 10000 + usePhraseHighlighter: true + highlightMultiTerm: true + preserveMulti: false + highlight: + mergeContiguous: false + requireFieldMatch: false + snippets: 3 + fragsize: 0 + mlt: + mintf: 1 + mindf: 1 + maxdf: 0 + maxdfpct: 0 + minwl: 0 + maxwl: 0 + maxqt: 100 + maxntp: 2000 + boost: false + interestingTerms: none + advanced: + index_prefix: '' + collection: '' + timezone: '' id: default name: Default description: '' @@ -48,6 +87,7 @@ field_settings: af_parts_of_day: label: 'Parts of day' property_path: search_api_af_parts_of_day + type: string af_weeks: label: Weeks property_path: search_api_af_weeks @@ -57,6 +97,9 @@ field_settings: datasource_id: 'entity:node' property_path: title type: text + dependencies: + module: + - node field_session_min_age: label: 'Min Age' datasource_id: 'entity:node' @@ -80,6 +123,9 @@ field_settings: type: boolean indexed_locked: true type_locked: true + dependencies: + module: + - node uid: label: uid datasource_id: 'entity:node' @@ -87,6 +133,9 @@ field_settings: type: integer indexed_locked: true type_locked: true + dependencies: + module: + - node field_activity_category: label: 'Program Subcategory' datasource_id: 'entity:node' @@ -99,8 +148,6 @@ field_settings: - field.storage.node.field_activity_category module: - node - - node - - node field_session_location: label: Location datasource_id: 'entity:node' @@ -118,15 +165,12 @@ field_settings: type: string dependencies: config: - - field.storage.node.field_session_class - - field.storage.node.field_class_activity - field.storage.node.field_activity_category - field.storage.node.field_category_program + - field.storage.node.field_class_activity + - field.storage.node.field_session_class module: - node - - node - - node - - node field_session_time_days: label: Days datasource_id: 'entity:node' @@ -196,6 +240,8 @@ processor_settings: content_access: weights: preprocess_query: -30 + language_with_fallback: { } + solr_date_range: { } tracker_settings: default: indexing_order: fifo diff --git a/modules/custom/openy_activity_finder/config/optional/search_api.server.solr.yml b/modules/custom/openy_activity_finder/config/optional/search_api.server.solr.yml index f6c2408db4..29e6054ce9 100644 --- a/modules/custom/openy_activity_finder/config/optional/search_api.server.solr.yml +++ b/modules/custom/openy_activity_finder/config/optional/search_api.server.solr.yml @@ -13,19 +13,31 @@ backend_config: scheme: http host: solr port: '8983' - path: /solr + path: '' core: collection1 timeout: 5 index_timeout: 5 optimize_timeout: 10 + finalize_timeout: 30 commit_within: 1000 solr_version: '' http_method: AUTO + jmx: false + solr_install_dir: '' + disabled_field_types: { } + disabled_caches: { } + disabled_request_handlers: + - request_handler_elevate_default_7_0_0 + - request_handler_replicationmaster_default_7_0_0 + - request_handler_replicationslave_default_7_0_0 + disabled_request_dispatchers: + - request_dispatcher_httpcaching_default_7_0_0 + rows: 10 retrieve_data: false highlight_data: false - excerpt: false skip_schema_check: false + server_prefix: '' + domain: generic + environment: default + optimize: false site_hash: true - suggest_suffix: true - suggest_corrections: true - suggest_words: false diff --git a/modules/custom/openy_search/openy_search_api/config/install/search_api.server.solr_search.yml b/modules/custom/openy_search/openy_search_api/config/install/search_api.server.solr_search.yml index a123588b95..a2a748183b 100644 --- a/modules/custom/openy_search/openy_search_api/config/install/search_api.server.solr_search.yml +++ b/modules/custom/openy_search/openy_search_api/config/install/search_api.server.solr_search.yml @@ -12,20 +12,33 @@ backend_config: connector_config: scheme: http host: solr - port: '8983' - path: /solr + port: 8983 + path: '' core: collection1 timeout: 5 index_timeout: 5 optimize_timeout: 10 + finalize_timeout: 10 commit_within: 1000 solr_version: '' http_method: AUTO + jmx: false + solr_install_dir: '' + username: '' + disabled_field_types: { } + disabled_caches: { } + disabled_request_handlers: + - request_handler_elevate_default_7_0_0 + - request_handler_replicationmaster_default_7_0_0 + - request_handler_replicationslave_default_7_0_0 + disabled_request_dispatchers: + - request_dispatcher_httpcaching_default_7_0_0 + rows: 10 retrieve_data: false highlight_data: false - excerpt: false skip_schema_check: false + server_prefix: '' + domain: generic + environment: default + optimize: false site_hash: true - suggest_suffix: true - suggest_corrections: true - suggest_words: true diff --git a/modules/custom/openy_search/openy_search_api/openy_search_api.install b/modules/custom/openy_search/openy_search_api/openy_search_api.install index 1ee6da883d..3555f150bb 100644 --- a/modules/custom/openy_search/openy_search_api/openy_search_api.install +++ b/modules/custom/openy_search/openy_search_api/openy_search_api.install @@ -72,3 +72,35 @@ function openy_search_api_uninstall() { } } } + +/** + * Enable Search API Solr legacy if needed. + */ +function openy_search_api_update_8001() { + $messages = []; + if (openy_enable_search_api_solr_legacy()) { + $messages[] = '***'; + $messages[] = '*** You are using a legacy version of Apache Solr. Enabling the Search API Solr Legacy module. ***'; + $messages[] = '***'; + $messages[] = ''; + } + $messages[] = '* MAJOR SOLR SEARCH MODULE UPGRADE (1.x to 4.x).'; + $messages[] = '*'; + $messages[] = '* Download the updated Apache Solr configuration form the Search API module configuration page.'; + $messages[] = '** On the page, find each individual Search server, click its name and download the config.zip using "Get config.zip" button.'; + $messages[] = '** Alternatively, use `drush solr-gsc YOUR_SEARCH_API_SERVER_ID` command.'; + $messages[] = '** Alternatively, use a jump-start configuration from https://git.drupalcode.org/project/search_api_solr/-/tree/4.x/jump-start'; + $messages[] = '* Apply the new Solr configuration. Ask your server administrator or a hosting support for assistance.'; + $messages[] = '* Reindex the associated Search API indexes.'; + $messages[] = '*'; + $messages[] = '* For more details see https://www.drupal.org/docs/8/modules/search-api-solr/search-api-solr-howtos/migrate-from-8x-1x-to-4x'; + $messages[] = '*'; + + $messenger = \Drupal::messenger(); + foreach ($messages as $message) { + $messenger->addMessage($message, 'warning'); + if (function_exists('drush_print')) { + drush_print($message); + } + } +} diff --git a/openy.profile b/openy.profile index 272ef463a8..66d499e2bb 100644 --- a/openy.profile +++ b/openy.profile @@ -279,6 +279,9 @@ function openy_install_search(array &$install_state) { foreach ($modules as $module) { $module_operations[] = ['openy_enable_module', (array) $module]; } + // todo: install search_api_solr_legacy. + $module_operations[] = ['openy_enable_search_api_solr_legacy', []]; + return ['operations' => $module_operations]; } @@ -766,3 +769,40 @@ function openy_terms_and_condition_db_save(&$install_state) { $config->set('accepted_version', time()); $config->save(); } + +/** + * Enables Search API Solr Legacy if Solr 4.x backend is detected. + * + * @return bool + * TRUE if the legacy module was enabled. + */ +function openy_enable_search_api_solr_legacy() { + $moduleHandler = \Drupal::service('module_handler'); + if (!$moduleHandler->moduleExists('search_api_solr')) { + return; + } + $storage = \Drupal::entityTypeManager() + ->getStorage('search_api_server'); + $search_api_servers = $storage->getQuery()->execute(); + + foreach ($search_api_servers as $search_api_server_id) { + $search_api_server = $storage->load($search_api_server_id); + if ($search_api_server->getBackendId() !== 'search_api_solr') { + continue; + } + if (!$search_api_server->hasValidBackend()) { + continue; + } + $connector = $search_api_server->getBackend()->getSolrConnector(); + $solr_version = $connector->getSolrVersion(); + $solr_version_forced = $connector->getSolrVersion(TRUE); + if (preg_match('/[45]{1}\.[0-9]+\.[0-9]+/', $solr_version) + || preg_match('/[45]{1}\.[0-9]+\.[0-9]+/', $solr_version_forced)) { + // Solr 4.x or 5.x found, install the Search API Solr Legacy module. + \Drupal::service('module_installer')->install(['search_api_solr_legacy']); + return TRUE; + } + } + + return FALSE; +} diff --git a/src/Form/SearchSolrForm.php b/src/Form/SearchSolrForm.php index d3230ff061..c70245f022 100644 --- a/src/Form/SearchSolrForm.php +++ b/src/Form/SearchSolrForm.php @@ -32,7 +32,7 @@ protected function getEditableConfigNames() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $solr_server_config = $this->config('search_api.server.openy_solr_search'); + $solr_server_config = $this->config('search_api.server.solr_search'); $backend_config = $solr_server_config->get('backend_config'); $solr_connector_options = [ From c8d0feaf44e2c9a77e01cbeb0cb09087ded9c1e7 Mon Sep 17 00:00:00 2001 From: andrey Date: Mon, 14 Sep 2020 13:12:01 +0300 Subject: [PATCH 2/2] [CR-22] Patch search_api_solr for Solr 4.x compatibility --- composer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/composer.json b/composer.json index a9a2996c6b..68b05b6878 100644 --- a/composer.json +++ b/composer.json @@ -196,6 +196,10 @@ }, "drupal/social_feed_fetcher": { "Fix incorrect core key value in info file": "https://www.drupal.org/files/issues/2020-04-23/3130364-2.patch" + }, + "drupal/search_api_solr": { + "Fix search_api_solr_cron() with Solr 4.x backend": "https://www.drupal.org/files/issues/2020-09-14/search_api_solr-solr_4_cron_fix-3170802.patch", + "Fix cores appear unavailable in UI with Solr 4.x backend": "https://www.drupal.org/files/issues/2020-09-14/search_api_solr-solr_4_core_unavailable_ui-3170793.patch" } } },