Skip to content

Commit

Permalink
Made the search better. Added support for nbs dynamic landing pages. …
Browse files Browse the repository at this point in the history
…Fixed some bugs
  • Loading branch information
Magnar Eivind Martinsen committed Oct 29, 2024
1 parent 4a64512 commit 531754b
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 88 deletions.
28 changes: 20 additions & 8 deletions metsis/metsis_lib/src/Controller/DynamicLandingPagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ public function getLandingPage(string $id, Request $request) {
$connector = $backend->getSolrConnector();

$solarium_query = $connector->getSelectQuery();
$solarium_query->setQuery('id:' . $id_prefix . '-' . $id);
if ($id_prefix === 'no-met-nbs') {
$solarium_query->setQuery('id:' . $id);
}
else {
$solarium_query->setQuery('id:' . $id_prefix . '-' . $id);
}
// $solarium_query->addSort('sequence_id', Query::SORT_ASC);.
$solarium_query->setRows(1);
// $fields[] = 'id';
Expand All @@ -189,6 +194,10 @@ public function getLandingPage(string $id, Request $request) {
foreach ($result as $doc) {
$fields = $doc->getFields();
}
if ($id_prefix === 'no-met-nbs') {
$mid = $fields['metadata_identifier'];
$fields['metadata_identifier'] = $id_prefix . ':' . $mid;
}
// dpm($fields);
if (NULL != $request->query->get('export_type')) {
$response = new Response();
Expand Down Expand Up @@ -408,7 +417,7 @@ public function getLandingPage(string $id, Request $request) {
}
}
}

// dpm($fields, __FUNCTION__);.
$renderArray['constraints_and_info']['metadata_information'] = [
'#type' => 'fieldset',
'#title' => $this->t('Metadata Information'),
Expand Down Expand Up @@ -822,7 +831,7 @@ public function getLandingPage(string $id, Request $request) {
$renderArray['#cache']['max-age'] = 31536000;

// ADD JSONLD META.
$jsonld = $this->getJsonld($fields, $host);
$jsonld = $this->getJsonld($fields, $host, $id_prefix);
$renderArray['#attached']['html_head'][] = [
[
'#type' => 'html_tag',
Expand Down Expand Up @@ -880,7 +889,7 @@ public function transformXml($xml, $type) {
/**
* Get json-ld.
*/
public function getJsonld($fields, $host) {
public function getJsonld($fields, $host, $id_prefix) {

$start_date = "";
$end_date = "";
Expand All @@ -892,16 +901,19 @@ public function getJsonld($fields, $host) {
if (isset($fields['temporal_extent_end_date'])) {
$end_date = $fields['temporal_extent_end_date'][0];
}

$mid = $fields['metadata_identifier'];
if ($id_prefix === 'no-met-nbs') {
$mid = explode(':', $fields['metadata_identifier'])[1];
}
$json = [
'@context' => 'https://schema.org/',
'@type' => 'Dataset',
'@id' => $fields['related_url_landing_page'][0],
'@id' => $fields['related_url_landing_page'][0] ?? '',
'name' => $fields['title'][0],
'description' => $fields['abstract'][0],
'url' => $fields['related_url_landing_page'][0],
'url' => $fields['related_url_landing_page'][0] ?? '',
'identifier' => [
$fields['metadata_identifier'],
$mid,
],
'keywords' => $fields['keywords_keyword'],
'license' => $fields['use_constraint_resource'] ?? "",
Expand Down
52 changes: 31 additions & 21 deletions metsis/metsis_search/config/install/search_api.index.metsis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ field_settings:
datasource_id: solr_document
property_path: abstract
type: text
boost: 1.3
boost: 1.2
access_constraint:
label: 'Access constraint'
datasource_id: solr_document
Expand Down Expand Up @@ -113,7 +113,7 @@ field_settings:
label: 'Data access_description'
datasource_id: solr_document
property_path: data_access_description
type: text
type: string
data_access_resource:
label: 'Data access_resource'
datasource_id: solr_document
Expand Down Expand Up @@ -203,7 +203,7 @@ field_settings:
label: 'Data center_long name'
datasource_id: solr_document
property_path: data_center_long_name
type: text
type: string
data_center_short_name:
label: 'Data center_short name'
datasource_id: solr_document
Expand All @@ -218,7 +218,7 @@ field_settings:
label: 'Dataset citation author'
datasource_id: solr_document
property_path: dataset_citation_author
type: text
type: string
dataset_citation_doi:
label: 'Dataset citation doi'
datasource_id: solr_document
Expand Down Expand Up @@ -325,7 +325,6 @@ field_settings:
datasource_id: solr_document
property_path: full_text
type: text
boost: 1.1
geographic_extent_ectangle_east:
label: 'Geographic extent_rectangle_east'
datasource_id: solr_document
Expand Down Expand Up @@ -381,6 +380,7 @@ field_settings:
datasource_id: solr_document
property_path: keywords_keyword
type: text
boost: 1.3
keywords_level1:
label: 'Keywords level1'
datasource_id: solr_document
Expand Down Expand Up @@ -425,7 +425,7 @@ field_settings:
label: 'Last metadata update'
datasource_id: solr_document
property_path: last_metadata_update
type: date
type: string
last_metadata_update_datetime:
label: 'Last metadata update_datetime'
datasource_id: solr_document
Expand Down Expand Up @@ -560,12 +560,12 @@ field_settings:
label: 'Personnel datacenter name'
datasource_id: solr_document
property_path: personnel_datacenter_name
type: text
type: string
personnel_datacenter_organisation:
label: 'Personnel datacenter organisation'
datasource_id: solr_document
property_path: personnel_datacenter_organisation
type: text
type: string
personnel_datacenter_phone:
label: 'Personnel datacenter phone'
datasource_id: solr_document
Expand Down Expand Up @@ -620,12 +620,12 @@ field_settings:
label: 'Personnel investigator name'
datasource_id: solr_document
property_path: personnel_investigator_name
type: text
type: string
personnel_investigator_organisation:
label: 'Personnel investigator organisation'
datasource_id: solr_document
property_path: personnel_investigator_organisation
type: text
type: string
personnel_investigator_phone:
label: 'Personnel investigator phone'
datasource_id: solr_document
Expand Down Expand Up @@ -675,12 +675,12 @@ field_settings:
label: 'Personnel metadata author name'
datasource_id: solr_document
property_path: personnel_metadata_author_name
type: text
type: string
personnel_metadata_author_organisation:
label: 'Personnel metadata author organisation'
datasource_id: solr_document
property_path: personnel_metadata_author_organisation
type: text
type: string
personnel_metadata_author_phone:
label: 'Personnel metadata author phone'
datasource_id: solr_document
Expand All @@ -696,6 +696,7 @@ field_settings:
datasource_id: solr_document
property_path: personnel_name
type: text
boost: 1.3
personnel_organisation:
label: Personnel_organisation
datasource_id: solr_document
Expand All @@ -706,6 +707,7 @@ field_settings:
datasource_id: solr_document
property_path: personnel_role
type: string
boost: 1.5
personnel_technical_address:
label: 'Personnel technical address'
datasource_id: solr_document
Expand Down Expand Up @@ -745,12 +747,12 @@ field_settings:
label: 'Personnel technical name'
datasource_id: solr_document
property_path: personnel_technical_name
type: text
type: string
personnel_technical_organisation:
label: 'Personnel technical organisation'
datasource_id: solr_document
property_path: personnel_technical_organisation
type: text
type: string
personnel_technical_phone:
label: 'Personnel technical phone'
datasource_id: solr_document
Expand All @@ -765,8 +767,8 @@ field_settings:
label: 'Phrase suggester'
datasource_id: solr_document
property_path: phrase_suggester
type: text
boost: 1.5
type: solr_text_suggester
boost: 1.4
platform_ancillary_cloud_coverage:
label: 'Platform ancillary cloud coverage'
datasource_id: solr_document
Expand All @@ -781,7 +783,7 @@ field_settings:
label: 'Platform instrument long name'
datasource_id: solr_document
property_path: platform_instrument_long_name
type: text
type: string
platform_instrument_mode:
label: 'Platform instrument mode'
datasource_id: solr_document
Expand Down Expand Up @@ -851,7 +853,7 @@ field_settings:
label: 'Project_long name'
datasource_id: solr_document
property_path: project_long_name
type: text
type: string
project_short_name:
label: 'Project_short name'
datasource_id: solr_document
Expand All @@ -876,7 +878,7 @@ field_settings:
label: 'Related information_description'
datasource_id: solr_document
property_path: related_information_description
type: text
type: string
related_information_resource:
label: 'Related information_resource'
datasource_id: solr_document
Expand Down Expand Up @@ -1112,12 +1114,19 @@ field_settings:
datasource_id: solr_document
property_path: temporal_extent_start_date
type: date
boost: 1.4
text_keywords_stemmed:
label: 'Keywords stemmed'
datasource_id: solr_document
property_path: text_keywords_stemmed
type: text
boost: 1.3
text_suggester:
label: 'Text suggester'
datasource_id: solr_document
property_path: text_suggester
type: solr_text_suggester
boost: 1.4
boost: 1.3
thumbnail_data:
label: 'Thumbnail data'
datasource_id: solr_document
Expand All @@ -1127,12 +1136,13 @@ field_settings:
label: 'Thumbnail URL'
datasource_id: solr_document
property_path: thumbnail_url
type: solr_string_storage
type: string
timestamp:
label: Timestamp
datasource_id: solr_document
property_path: timestamp
type: date
boost: 1.5
title:
label: Title
datasource_id: solr_document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ field_settings:
datasource_id: solr_document
property_path: full_text
type: text
boost: 1.1
id:
label: Id
datasource_id: solr_document
Expand All @@ -142,12 +141,19 @@ field_settings:
datasource_id: solr_document
property_path: metadata_status
type: string
boost: 1.5
personnel_name:
label: 'Personnel name'
datasource_id: solr_document
property_path: personnel_name
type: text
boost: 1.4
phrase_suggester:
label: 'Phrase suggester'
datasource_id: solr_document
property_path: phrase_suggester
type: text
boost: 1.5
type: solr_text_suggester
boost: 1.4
project_long_name:
label: 'Project long name'
datasource_id: solr_document
Expand Down Expand Up @@ -182,7 +188,7 @@ field_settings:
label: 'Ss language'
datasource_id: solr_document
property_path: ss_language
type: string
type: date
temporal_extent_end_date:
label: 'Temporal extent end date'
datasource_id: solr_document
Expand All @@ -198,22 +204,30 @@ field_settings:
datasource_id: solr_document
property_path: temporal_extent_start_date
type: date
boost: 1.3
text_keywords_stemmed:
label: 'Keywords stemmed'
datasource_id: solr_document
property_path: text_keywords_stemmed
type: text
boost: 1.2
text_suggester:
label: 'Text suggester'
datasource_id: solr_document
property_path: text_suggester
type: text
type: solr_text_suggester
boost: 1.3
thumbnail_url:
label: 'Thumbnail URL'
datasource_id: solr_document
property_path: thumbnail_url
type: string
boost: 1.5
timestamp:
label: Timestamp
datasource_id: solr_document
property_path: timestamp
type: text
type: date
boost: 1.5
title:
label: Title
Expand Down
Loading

0 comments on commit 531754b

Please sign in to comment.