Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-11003: Update platform config #507

Merged
merged 17 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
"drupal/purge": "^3.0",
"drupal/varnish_purge": "^2.1",
"drush/drush": "^12",
"elasticsearch/elasticsearch": "^7.15",
"josdejong/jsoneditor": "^5.29",
"league/csv": "^9.8",
"paatokset/paatokset_search": "1.2.2"
"paatokset/paatokset_search": "1.3.1-dev"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
Expand Down Expand Up @@ -151,9 +150,9 @@
"type": "package",
"package": {
"name": "paatokset/paatokset_search",
"version": "1.2.2",
"version": "1.3.1-dev",
"dist": {
"url": "https://github.com/City-of-Helsinki/paatokset-search/releases/download/1.2.2/paatokset_search.zip",
"url": "https://github.com/City-of-Helsinki/paatokset-search/releases/download/1.3.1-dev/paatokset_search.zip",
"type": "zip"
}
}
Expand Down
1,483 changes: 655 additions & 828 deletions composer.lock

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions conf/cmi/elasticsearch_connector.cluster.paatokset.yml

This file was deleted.

24 changes: 16 additions & 8 deletions conf/cmi/search_api.index.decisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ langcode: en
status: true
dependencies:
config:
- field.storage.node.field_decision_case_title
- field.storage.node.field_classification_title
- field.storage.node.field_decision_content_parsed
- field.storage.node.field_decision_motion_parsed
- field.storage.node.field_decision_section
- field.storage.node.field_is_decision
- field.storage.node.field_policymaker_id
- field.storage.node.field_decision_native_id
- field.storage.node.field_diary_number
- field.storage.node.field_decision_case_title
- field.storage.node.field_full_title
- field.storage.node.field_meeting_date
- field.storage.node.field_decision_native_id
- field.storage.node.field_is_decision
- field.storage.node.field_policymaker_id
- field.storage.node.field_dm_org_above_name
- field.storage.node.field_dm_org_name
- field.storage.node.field_organization_type
- field.storage.node.field_full_title
- field.storage.node.field_decision_section
- field.storage.node.field_top_category_name
- search_api.server.elasticsearch
- search_api.server.default
module:
- node
- search_api
Expand All @@ -29,6 +29,14 @@ name: Decisions
description: ''
read_only: false
field_settings:
_language:
label: Language
datasource_id: 'entity:node'
property_path: langcode
type: string
dependencies:
module:
- node
category_name:
label: 'Classification title'
datasource_id: 'entity:node'
Expand Down Expand Up @@ -262,4 +270,4 @@ options:
cron_limit: 0
index_directly: false
track_changes_in_references: true
server: elasticsearch
server: default
12 changes: 10 additions & 2 deletions conf/cmi/search_api.index.meetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- field.storage.node.field_meeting_sequence_number
- field.storage.node.field_meeting_minutes_published
- field.storage.node.field_meeting_status
- search_api.server.elasticsearch
- search_api.server.default
module:
- node
- search_api
Expand All @@ -22,6 +22,14 @@ name: Meetings
description: ''
read_only: false
field_settings:
_language:
label: Language
datasource_id: 'entity:node'
property_path: langcode
type: string
dependencies:
module:
- node
field_meeting_agenda_published:
label: 'Agenda published'
datasource_id: 'entity:node'
Expand Down Expand Up @@ -180,4 +188,4 @@ options:
cron_limit: 0
index_directly: false
track_changes_in_references: true
server: elasticsearch
server: default
12 changes: 10 additions & 2 deletions conf/cmi/search_api.index.policymakers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- field.storage.node.field_organization_type
- field.storage.node.field_ahjo_title
- field.storage.node.field_sector_name
- search_api.server.elasticsearch
- search_api.server.default
module:
- node
- search_api
Expand All @@ -22,6 +22,14 @@ name: Policymakers
description: ''
read_only: false
field_settings:
_language:
label: Language
datasource_id: 'entity:node'
property_path: langcode
type: string
dependencies:
module:
- node
color_class:
label: 'Color Class'
datasource_id: 'entity:node'
Expand Down Expand Up @@ -199,4 +207,4 @@ options:
cron_limit: 0
index_directly: false
track_changes_in_references: true
server: elasticsearch
server: default
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ status: true
dependencies:
module:
- elasticsearch_connector
id: elasticsearch
id: default
name: Elasticsearch
description: ''
backend: elasticsearch
backend_config:
cluster_settings:
cluster: paatokset
fuzziness: auto
connector: standard
connector_config:
url: 'http://elastic:9200'
enable_debug_logging: false
advanced:
fuzziness: auto
prefix: paatokset_
suffix: ''
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
<?php

declare(strict_types=1);

namespace Drupal\paatokset_search\EventSubscriber;

use Drupal\elasticsearch_connector\Event\PrepareIndexEvent;
use Drupal\Component\Utility\NestedArray;
use Drupal\elasticsearch_connector\Event\AlterSettingsEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* {@inheritdoc}
* Elasticsearch event subscriber.
*/
class PrepareIndex implements EventSubscriberInterface {

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
return [
PrepareIndexEvent::PREPARE_INDEX => 'prepareIndices',
AlterSettingsEvent::class => 'prepareIndices',
];
}

/**
* Method to prepare index.
*
* @param Drupal\elasticsearch_connector\Event\PrepareIndexEvent $event
* @param \Drupal\elasticsearch_connector\Event\AlterSettingsEvent $event
* The PrepareIndex event.
*/
public function prepareIndices(PrepareIndexEvent $event) {
$indexName = $event->getIndexName();
public function prepareIndices(AlterSettingsEvent $event): void {
$indexName = $event->getIndex()->id();
$finnishIndices = [
'paatokset_decisions',
'paatokset_policymakers',
];
if (in_array($indexName, $finnishIndices)) {
$indexConfig = $event->getIndexConfig();
$indexConfig['body']['settings']['analysis']['analyzer']['default']['type'] = 'finnish';
$event->setIndexConfig($indexConfig);
$event->setSettings(NestedArray::mergeDeep(
$event->getSettings(),
[
'analysis' => [
'analyzer' => [
'default' => [
'type' => 'finnish',
],
],
],
],
));
}
}

Expand Down
11 changes: 5 additions & 6 deletions public/sites/default/all.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@

// Elasticsearch settings.
if (getenv('ELASTIC_CONNECTOR_URL')) {
$config['elasticsearch_connector.cluster.paatokset']['url'] = getenv('ELASTIC_CONNECTOR_URL');
$config['search_api.server.elastic_rekry']['backend_config']['connector_config']['url'] = getenv('ELASTIC_CONNECTOR_URL');
hyrsky marked this conversation as resolved.
Show resolved Hide resolved

if (getenv('ELASTIC_INTERNAL_USER') && getenv('ELASTIC_INTERNAL_PWD')) {
$config['elasticsearch_connector.cluster.paatokset']['options']['use_authentication'] = '1';
$config['elasticsearch_connector.cluster.paatokset']['options']['authentication_type'] = 'Basic';
$config['elasticsearch_connector.cluster.paatokset']['options']['username'] = getenv('ELASTIC_INTERNAL_USER');
$config['elasticsearch_connector.cluster.paatokset']['options']['password'] = getenv('ELASTIC_INTERNAL_PWD');
if (getenv('ELASTIC_USER') && getenv('ELASTIC_PASSWORD')) {
$config['search_api.server.elastic_rekry']['backend_config']['connector'] = 'basicauth';
$config['search_api.server.elastic_rekry']['backend_config']['connector_config']['username'] = getenv('ELASTIC_INTERNAL_USER');
$config['search_api.server.elastic_rekry']['backend_config']['connector_config']['password'] = getenv('ELASTIC_INTERNAL_PWD');
}
}

Expand Down