Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/3.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-gao committed Mar 11, 2022
2 parents 0061b51 + ba1d3bc commit cec38f1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
16 changes: 12 additions & 4 deletions config/install/search_api.index.node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
- field.storage.node.body
- field.storage.node.field_topic
- field.storage.node.field_tags
- field.storage.node.field_landing_page_summary
- search_api.server.elasticsearch_bay
module:
- taxonomy
Expand Down Expand Up @@ -53,8 +54,7 @@ field_settings:
label: 'Topic » Taxonomy term » Name'
datasource_id: 'entity:node'
property_path: 'field_topic:entity:name'
type: text
boost: !!float 5
type: string
dependencies:
config:
- field.storage.node.field_topic
Expand All @@ -75,8 +75,7 @@ field_settings:
label: 'Tags » Taxonomy term » Name'
datasource_id: 'entity:node'
property_path: 'field_tags:entity:name'
type: text
boost: !!float 5
type: string
dependencies:
config:
- field.storage.node.field_tags
Expand Down Expand Up @@ -140,6 +139,14 @@ field_settings:
- field.storage.node.field_topic
module:
- taxonomy
field_landing_page_summary:
label: Summary
datasource_id: 'entity:node'
property_path: field_landing_page_summary
type: text
dependencies:
config:
- field.storage.node.field_landing_page_summary
nid:
label: ID
datasource_id: 'entity:node'
Expand Down Expand Up @@ -195,6 +202,7 @@ processor_settings:
- field_tags_path
- uuid
- field_tags_uuid
- field_landing_page_summary
- field_topic_uuid
- type
- langcode
Expand Down
46 changes: 46 additions & 0 deletions tide_search.install
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,49 @@ function tide_search_update_8001() {

$index->save();
}

/**
* Adds field_landing_page_summary field to search api, and updates settings.
*/
function tide_search_update_8002() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('search_api.index.node');
$dependencies = $config->get('dependencies.config');
if (!in_array('field.storage.node.field_landing_page_summary', $dependencies)) {
$dependencies[] = 'field.storage.node.field_landing_page_summary';
$config->set('dependencies.config', $dependencies);
}
$field_settings = $config->get('field_settings');
if (isset($field_settings['field_topic_name']['type']) && $field_settings['field_topic_name']['type'] === 'text') {
$field_settings['field_topic_name']['type'] = 'string';
if (isset($field_settings['field_topic_name']['boost'])) {
unset($field_settings['field_topic_name']['boost']);
}
}
if (isset($field_settings['field_tags_name']['type']) && $field_settings['field_tags_name']['type'] === 'text') {
$field_settings['field_tags_name']['type'] = 'string';
if (isset($field_settings['field_tags_name']['boost'])) {
unset($field_settings['field_tags_name']['boost']);
}
}
if (!isset($field_settings['field_landing_page_summary'])) {
$field_settings['field_landing_page_summary'] = [
'label' => 'Summary',
'datasource_id' => 'entity:node',
'property_path' => 'field_landing_page_summary',
'type' => 'text',
'dependencies' => [
'config' => [
'field.storage.node.field_landing_page_summary',
],
],
];
$config->set('field_settings', $field_settings);
}
$processor_settings = $config->get('processor_settings.html_filter.fields');
if (!in_array('field_landing_page_summary', $processor_settings)) {
$processor_settings[] = 'field_landing_page_summary';
$config->set('processor_settings.html_filter.fields', $processor_settings);
}
$config->save();
}

0 comments on commit cec38f1

Please sign in to comment.