From d3cdabd53c79ce2f2680021be73e9e8fadc09cba Mon Sep 17 00:00:00 2001 From: Kate Pechekhonova Date: Sun, 14 May 2017 22:52:23 -0400 Subject: [PATCH 1/3] Added new fields for advanced search --- modules/dlts_solr/dlts_solr.module | 58 +++---- modules/dlts_solr/inc/book.inc | 42 ++++- modules/dlts_solr/inc/series.inc | 207 ++++++++++++++++++------- modules/dlts_solr/inc/translations.inc | 18 ++- 4 files changed, 218 insertions(+), 107 deletions(-) diff --git a/modules/dlts_solr/dlts_solr.module b/modules/dlts_solr/dlts_solr.module index 91b83da2..51a28b23 100755 --- a/modules/dlts_solr/dlts_solr.module +++ b/modules/dlts_solr/dlts_solr.module @@ -1,37 +1,5 @@ key(array('entity_type' => $type, 'entity_id' => $id)) - //->insertFields(array('entity_type' => $type, 'entity_id' => $id, 'bundle' => $bundle, 'status' => 1)) - //->fields(array('changed' => REQUEST_TIME)) - //->execute(); - //$id = 8091; - //db_merge($indexer_table)->key(array('entity_type' => $type, 'entity_id' => $id)) - //->insertFields(array('entity_type' => $type, 'entity_id' => $id, 'bundle' => $bundle, 'status' => 1)) - //->fields(array('changed' => REQUEST_TIME)) - //->execute(); - //$id = 2840; - //db_merge($indexer_table)->key(array('entity_type' => $type, 'entity_id' => $id)) - //->insertFields(array('entity_type' => $type, 'entity_id' => $id, 'bundle' => $bundle, 'status' => 1)) - //->fields(array('changed' => REQUEST_TIME)) - //->execute(); -} - function dlts_solr_node_update($node) { $bundle = 'dlts_book'; if ($node->type == $bundle && $node->language != 'en') { @@ -90,13 +58,6 @@ function dlts_solr_apachesolr_index_document_build(ApacheSolrDocument $document, /** pass the document as reference */ dlts_solr_index_book($document, $entity, $entity_type, $env_id); break; - case 'dlts_series' : - /** load utils */ - module_load_include('inc', 'dlts_solr', 'inc/series'); - /** pass the document as reference */ - dlts_solr_index_series($document, $entity, $entity_type, $env_id); - break; - } } @@ -176,6 +137,16 @@ function seems_utf8( $str ) { return true; } +/** +*cleanup for arabic characters +*/ +function dlts_solr_remove_special_cahrs($string) { + //remove modified letter turn comma + $string=preg_replace('/[\x{02BB}-\x{02BD}]+/u','',$string); + //remove special characters + $string=preg_replace('/(\,|\[|]|\.|}|\{)/','',$string); + return $string; +} /** * Taken from: https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-includes/formatting.php * Converts all accent characters to ASCII characters. @@ -188,6 +159,11 @@ function seems_utf8( $str ) { * @return string Filtered string with replaced "nice" characters. */ function dlts_solr_remove_accents($string) { + + //remove modified letter turn comma + $string=preg_replace('/[\x{02BB}-\x{02BD}]+/u','',$string); + //remove special characters + $string=preg_replace('/(\,|\[|]|\.|}|\{)/','',$string); if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; @@ -395,6 +371,8 @@ function dlts_solr_remove_accents($string) { //remove combined diacritics $string=preg_replace('/[\x{0300}-\x{036f}]+/u','',$string); //remove modified letter turn comma - $string=preg_replace('/\x{02BB}+/u','',$string); + $string=preg_replace('/[\x{02BB}-\x{02BD}]+/u','',$string); + //remove special characters + $string=preg_replace('/(\,|\[|]|\.|}|\{)/','',$string); return $string; } diff --git a/modules/dlts_solr/inc/book.inc b/modules/dlts_solr/inc/book.inc index 4e6f9e06..f51944e1 100755 --- a/modules/dlts_solr/inc/book.inc +++ b/modules/dlts_solr/inc/book.inc @@ -131,6 +131,8 @@ function dlts_solr_index_book_partners($items = array(), &$document, &$entity, & $document->addField('sm_' . $prefix . 'provider_label', $label); } if ($language == 'en') { + $document->addField('sm_sprovider_label', strtolower($label)); + $document->addField('tum_provider_label', $label); $document->addField('zm_partner',json_encode(array('name'=>$label,'code' => $code, 'nid' => $item->nid))); $document->addField('zm_provider',json_encode(array('name'=>$label,'code' => $code, 'nid' => $item->nid))); } @@ -323,6 +325,8 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { // we need to wait until we figure out if this is a multi volume. // by now, we already test for multi volume and title should be the right one. $document->addField('ss_title_long', $book_field_title); + $document->addField('ss_stitle_long', strtolower(dlts_solr_remove_accents($book_field_title))); + $document->addField('tus_stitle_long', strtolower(dlts_solr_remove_accents($book_field_title))); $searchableFields[] = dlts_solr_remove_accents($book_field_title); /** Subtitle (field_subtitle) */ /** single-value field */ @@ -392,6 +396,8 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { $document->addField('iass_author', dlts_solr_remove_accents(strtolower($author))); } $document->addField('sm_author', $author); + $document->addField('tum_author', dlts_solr_remove_accents($author)); + $document->addField('sm_sauthor', strtolower(dlts_solr_remove_accents($author))); } } unset($authors); @@ -434,7 +440,9 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { $publishers = $wrapper->field_publisher->value(); if (!empty($publishers)) { foreach ($publishers as $publisher) { - $document->addField('sm_publisher', $publisher); + $document->addField('sm_publisher', $publisher); + $document->addField('tum_publisher', dlts_solr_remove_accents($publisher)); + $document->addField('sm_spublisher', strtolower(dlts_solr_remove_accents($publisher))); $searchableFields[] = dlts_solr_remove_accents($publisher); } } @@ -443,6 +451,7 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { /** Publication date (field_publication_date) */ /** single-value field */ $publication_date = $wrapper->field_publication_date->value(); + $publication_date_text = $wrapper->field_publication_date_text->value(); if (!empty($publication_date) && !empty($publication_date['value'])) { /** convert ISO format into UNIX timestamp */ $timestamp = strtotime($publication_date['value']); @@ -453,17 +462,36 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { $document->addField('sort_pubyear', $publication_year); $document->addField('iass_pubyear', $publication_year); $document->addField('iass_timestamp', $timestamp); - } + } else { + if (!empty($publication_date_text)) { + $publication_date_text_norm=preg_replace('(u|?)','0',$publication_date_text); + preg_match_all('\b\d{4}\b', $publication_date_text_norm, $years); + if(!empty($years)) { + foreach ($years as $index => $publication_year) { + $searchableFields[] = $publication_year; + if ($index == 0) { + $document->addField('sort_pubyear', $publication_year); + $document->addField('iass_pubyear', $publication_year); + } + $document->addField('dm_pubyear', date('Y-m-d\TG:i:s', strtotime($publication_year))); + } + } + } + + } } unset($publication_date); + unset($publication_year); /** Publication date (field_publication_date) */ /** single-value field */ - $publication_date_text = $wrapper->field_publication_date_text->value(); + if (!empty($publication_date_text)) { /** @TODO: Find the right field for this field */ $document->addField('ss_publication_date_text', $publication_date_text); $document->addField('ss_pubdate', $publication_date_text); // remove this? $document->addField('ss_spubdate', strtolower($publication_date_text)); + } else { + } unset($publication_date_text); /** Publication location (field_publication_location) */ @@ -472,8 +500,9 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { if (!empty($publication_location)) { $searchableFields[] = dlts_solr_remove_accents($publication_location); $document->addField('ss_publication_location', $publication_location); - $document->addField('ss_publocation',dlts_solr_remove_accents($publication_location)); // remove this? @kate- when search options are fixed - $document->addField('ss_spublocation', dlts_solr_remove_accents($publication_location)); + $document->addField('ss_spublocation', strtolower(dlts_solr_remove_accents($publication_location))); + $document->addField('ss_publocation', $publication_location); // remove this? @kate- when search options are fixed + $document->addField('tus_spublocation', dlts_solr_remove_accents($publication_location)); } unset($publication_location); /** Subject (field_subject) */ @@ -482,6 +511,8 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { if (!empty($subjects)) { foreach ($subjects as $index=>$subject) { $document->addField('sm_subject_label', $subject->name); + $document->addField('sm_ssubject_label', strtolower(dlts_solr_remove_accents($subject->name))); + $document->addField('tum_ssubject_label', strtolower(dlts_solr_remove_accents($subject->name))); $searchableFields[] = dlts_solr_remove_accents($subject->name); if ($index == 0) { $document->addField('ss_ssubject', strtolower(dlts_solr_remove_accents($subject->name))); @@ -543,6 +574,7 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { /** Sort fields */ $document->addField('ss_longlabel', $title_sort); $document->addField('iass_longlabel', $title_sort); + $document->addField('tus_longlabel', $title_sort); /** add translations */ dlts_solr_index_book_translations($document, $entity, $entity_type, $env_id, $searchableFields); unset($document->content); diff --git a/modules/dlts_solr/inc/series.inc b/modules/dlts_solr/inc/series.inc index 1c1945cc..a79573c2 100755 --- a/modules/dlts_solr/inc/series.inc +++ b/modules/dlts_solr/inc/series.inc @@ -1,57 +1,32 @@ language; - - $prefix = ''; - - if ($language != 'en') { - $prefix = $language . '_'; - } +$series_data = array () ; - $data = array(); +$series_data['collections'] = array () ; - $data['collections'] = array(); +$series_data['books'] = array () ; - $data['books'] = array(); +/** add series utilities functions */ +module_load_include('inc', 'dlts_utilities', 'inc/dlts_utilities.series'); - $query = new EntityFieldQuery; +/** find the nids of all the books that belong to this series */ +$books_nids = dlts_utilities_series_books_nids ( $entity ) ; - $nids = array(); + if ( $books_nids ) { - $series_wrapper = entity_metadata_wrapper('node', $entity); - - $series_identifier = $series_wrapper->field_identifier->value(); + /** load the series book */ + $series_books = node_load_multiple ( $books_nids ) ; - // field data from node - $document->addField('ss_identifier', $series_identifier); - // field data from node - $document->addField('ss_series_identifier', $series_identifier); - // field data from node - $document->addField('ss_series_label', $entity->title); - - // find books associated with this series - $result = $query->entityCondition('entity_type', 'node') - ->entityCondition('bundle', 'dlts_series_book') - ->fieldCondition('field_series', 'nid', array($entity->nid)) - ->execute(); + foreach ( $series_books as $series_book ) { - if (!empty($result['node'])) { + // Wrap it with Entity API + $series_book_wrapper = entity_metadata_wrapper('node', $series_book); - $nids = array_keys($result['node']); + $collections = $series_book_wrapper->field_collection->value(); - /** load the series book */ - $nodes = node_load_multiple($nids); - - foreach ($nodes as $node) { - - // Wrap it with Entity API - $wrapper = entity_metadata_wrapper('node', $node); - - $collections = $wrapper->field_collection->value(); - - foreach ($collections as $collection) { + foreach ( $collections as $collection ) { $collection_wrapper = entity_metadata_wrapper('node', $collection); @@ -60,21 +35,141 @@ function dlts_solr_index_series($document, $entity, $entity_type, $env_id) { $collection_identifier = $collection_wrapper->field_identifier->value(); $collection_code = $collection_wrapper->field_code->value(); - - if (!isset($data['collections'][$collection_identifier])) { - $data['collections'][$collection_identifier] = array('label' => $collection_label, 'identifier' => $collection_identifier, 'code' => $collection_code); + + if ( ! isset ( $series_data['collections'][$collection_identifier] ) ) { + $series_data['collections'][$collection_identifier] = array ( + 'label' => $collection_label, + 'identifier' => $collection_identifier, + 'code' => $collection_code, + ); + } + + } + + $book = $series_book_wrapper->field_book->value(); + + if ( $book ) { + + $book_wrapper = entity_metadata_wrapper('node', $book); + + $volume = $series_book_wrapper->field_volume_number->value(); + + $book_identifier = $book_wrapper->field_identifier->value() ; + + $book_representative_image = $book_wrapper->field_representative_image->value() ; + + $book_label = $book_wrapper->field_title->value() ; + + if ( ! isset ( $series_data['books'][$book_identifier] ) ) { + + $series_data['books'][$book_identifier] = array () ; + + $series_data['books'][$book_identifier]['identifier'] = $book_identifier; + + $series_data['books'][$book_identifier]['label'] = $book_label; + + $partners = dlts_utilities_book_get_partner($book); + + $authors = dlts_utilities_book_get_authors($book); + + $creators = dlts_utilities_book_get_creator($book); + + $contributors = dlts_utilities_book_get_contributor($book); + + $publishers = dlts_utilities_book_get_publisher($book); + + $editors = dlts_utilities_book_get_editor($book); + + $publication_location = dlts_utilities_book_get_publication_location($book); + + $publication_date = dlts_utilities_book_get_field_publication_date_text($book); + + $subjects_list = dlts_utilities_book_get_subjects($book); + + if ( $multivol = dlts_utilities_book_get_multivol_book( $book ) ) { + if ( $volume = dlts_utilities_multibook_get_volume( $multivol ) ) { + $book_field_title = t('@title Vol. @volume', array( '@title' => $book_field_title, '@volume' => $volume ) ); + } + } + + if ( $series = dlts_utilities_book_get_series_book( $book ) ) { + if ( $series_volume = dlts_utilities_series_get_volume ( $series ) ) { + $book_series_title = t('@title ser. @volume', array( '@title' => $book_field_title, '@volume' => $series_volume ) ); + } + } + + $series_data['books'][$book_identifier]['partners'] = array(); + foreach ( $partners as $partner ) { + $series_data['books'][$book_identifier]['partners'][] = array ( 'value' => $partner); + } + + $series_data['books'][$book_identifier]['authors'] = array(); + foreach ( $authors as $author ) { + $series_data['books'][$book_identifier]['authors'][] = array ( 'value' => $author); + } + + $series_data['books'][$book_identifier]['contributors'] = array(); + foreach ( $contributors as $contributor ) { + $series_data['books'][$book_identifier]['contributors'][] = array ( 'value' => $contributor); + } + + $series_data['books'][$book_identifier]['creators'] = array(); + foreach ( $creators as $creator ) { + $series_data['books'][$book_identifier]['creators'][] = array ( 'value' => $creator); + } + + $series_data['books'][$book_identifier]['publishers'] = array(); + foreach ( $publishers as $publisher ) { + $series_data['books'][$book_identifier]['publishers'][] = array ( 'value' => $publisher); + } + + $series_data['books'][$book_identifier]['editors'] = array(); + foreach ( $editors as $editor ) { + $series_data['books'][$book_identifier]['editors'][] = array ( 'value' => $editor); + } + + $series_data['books'][$book_identifier]['subjects'] = array(); + foreach ( $subjects_list as $subject ) { + $series_data['books'][$book_identifier]['subjects'] = array ( 'tid' => $subject->tid, 'label' => $subject->name ) ; + } + + $series_data['books'][$book_identifier]['publication_location'] = $publication_location ; + + $series_data['books'][$book_identifier]['publication_date'] = $publication_date ; + + if ( $book_representative_image ) { + $series_data['books'][$book_identifier]['representative_image_medium'] = image_style_url('medium', $book_representative_image['uri']) ; + $series_data['books'][$book_identifier]['representative_image_thumbnail'] = image_style_url('thumbnail', $book_representative_image['uri']) ; + } + } } - - } - } - - foreach ($data['collections'] as $collection ) { - $document->addField('sm_series_collection_identifier', $collection['identifier']); - $document->addField('sm_series_code', $collection['code']); - } - - $document->addField('zs_data', json_encode($data)); - -} + + } + + } + + $series_wrapper = entity_metadata_wrapper('node', $entity); + + $document->addField('ss_series_label', $entity->title ) ; + + $series_identifier = $series_wrapper->field_identifier->value() ; + + $series_representative_image = $series_wrapper->field_representative_image->value() ; + + if ( $series_representative_image ) { + $styles = array_keys ( image_styles() ) ; + foreach ( $styles as $style ) { + $document->addField('zs_image_' . $style , image_style_url( $style, $series_representative_image['uri'] ) ) ; + } + } + + $document->addField('ss_identifier', $series_identifier ) ; + + foreach ( $series_data['collections'] as $collection ) { + $document->addField('sm_series_collection_identifier', $collection['identifier']) ; + $document->addField('sm_series_code', $collection['code']) ; + } + + $document->addField('zs_data', json_encode( $series_data )) ; diff --git a/modules/dlts_solr/inc/translations.inc b/modules/dlts_solr/inc/translations.inc index ca2bf80e..68a68346 100755 --- a/modules/dlts_solr/inc/translations.inc +++ b/modules/dlts_solr/inc/translations.inc @@ -9,7 +9,7 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ $node = node_load($translation->nid); $language = $node->language; $prefix = '_' . $language; - // wrapp entity with Entity API wrapper + // wrapp entity with Entity API wrapper: $wrapper = entity_metadata_wrapper('node', $node); /** Title (field_title) */ @@ -31,9 +31,11 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ $title_long = trim($title_long); /** Added temporarily to accomodate search options should be removed later-@ekate */ $document->addField('ss' . $prefix . '_title', dlts_solr_remove_accents(strtolower($title_long))); - $document->addField('ss' . $prefix . '_stitle', dlts_solr_remove_accents(strtolower($title_long))); + $document->addField('ss' . $prefix . '_stitle', dlts_solr_remove_accents($title_long)); $document->addField('iass' . $prefix . '_longlabel', dlts_solr_remove_accents(strtolower($title_long))); $document->addField('ss' . $prefix . '_title_long', $title_long); + $document->addField('tus' . $prefix . '_stitle_long', $title_long); + $document->addField('ss' . $prefix . '_stitle_long', dlts_solr_remove_special_cahrs($title_long)); $searchableFields[] = $title_long; unset($title_long); /** multi-value field */ @@ -48,9 +50,10 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ $searchableFields[] = $author; if ($index == 0) { $document->addField('ss' . $prefix . '_sauthor', dlts_solr_remove_accents(strtolower($author))); - $document->addField('iass' . $prefix . '_author', dlts_solr_remove_accents(strtolower($author))); + $document->addField('iass' . $prefix . '_author', strtolower(dlts_solr_remove_accents($author))); } - $document->addField('sm' . $prefix . '_author', $author); + $document->addField('sm' . $prefix . '_sauthor', strtolower( dlts_solr_remove_special_cahrs($author))); + $document->addField('tum' . $prefix . '_author', $author); } } unset($authors); @@ -94,6 +97,8 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ if (!empty($publishers)) { foreach ($publishers as $publisher) { $document->addField('sm' . $prefix . '_publisher', $publisher); + $document->addField('sm' . $prefix . '_spublisher', strtolower( dlts_solr_remove_special_cahrs($publisher))); + $document->addField('tum' . $prefix . '_publisher', $publisher); $searchableFields[] = $publisher; } } @@ -105,9 +110,10 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ if (!empty($publication_location)) { $searchableFields[] = $publication_location; $document->addField('ss' . $prefix . '_publication_location', $publication_location); - $document->addField('ss' . $prefix . '_spublocation', dlts_solr_remove_accents(strtolower($publication_location))); + $document->addField('ss' . $prefix . '_spublocation', strtolower( dlts_solr_remove_special_cahrs($publication_location))); /** add temporarily to accomodate current search options will remove later- @ekate */ - $document->addField('ss' . $prefix . '_publocation', dlts_solr_remove_accents(strtolower($publication_location))); + $document->addField('ss' . $prefix . '_publocation', $publication_location); + $document->addField('tus' . $prefix . '_publocation', $publication_location); } unset($publication_location); } From 5296f8835146a895bc71044262e63c2dbf59cb7d Mon Sep 17 00:00:00 2001 From: Kate Pechekhonova Date: Tue, 16 May 2017 00:40:50 -0400 Subject: [PATCH 2/3] One more fix for diacritics - need to do it in solr --- modules/dlts_solr/dlts_solr.module | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/dlts_solr/dlts_solr.module b/modules/dlts_solr/dlts_solr.module index 51a28b23..8d509f7c 100755 --- a/modules/dlts_solr/dlts_solr.module +++ b/modules/dlts_solr/dlts_solr.module @@ -372,6 +372,8 @@ function dlts_solr_remove_accents($string) { $string=preg_replace('/[\x{0300}-\x{036f}]+/u','',$string); //remove modified letter turn comma $string=preg_replace('/[\x{02BB}-\x{02BD}]+/u','',$string); + //remove additional diacritics - enough with that need to do all this in solr + $string=preg_replace('/[\x{1E25}]+/u','h',$string); //remove special characters $string=preg_replace('/(\,|\[|]|\.|}|\{)/','',$string); return $string; From b109f96b763b2eb1581aa5e8ba329570b4346843 Mon Sep 17 00:00:00 2001 From: Ekaterina Penchekhonova Date: Mon, 5 Jun 2017 18:27:41 -0400 Subject: [PATCH 3/3] Moved data clean up to solr itself, deleted not-used fields. Some additional cleanup will be needed --- modules/dlts_solr/inc/book.inc | 25 +++++-------------------- modules/dlts_solr/inc/translations.inc | 25 ++++++++++--------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/modules/dlts_solr/inc/book.inc b/modules/dlts_solr/inc/book.inc index f51944e1..102da3c8 100755 --- a/modules/dlts_solr/inc/book.inc +++ b/modules/dlts_solr/inc/book.inc @@ -325,8 +325,6 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { // we need to wait until we figure out if this is a multi volume. // by now, we already test for multi volume and title should be the right one. $document->addField('ss_title_long', $book_field_title); - $document->addField('ss_stitle_long', strtolower(dlts_solr_remove_accents($book_field_title))); - $document->addField('tus_stitle_long', strtolower(dlts_solr_remove_accents($book_field_title))); $searchableFields[] = dlts_solr_remove_accents($book_field_title); /** Subtitle (field_subtitle) */ /** single-value field */ @@ -389,15 +387,11 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { if (!empty($authors)) { foreach ($authors as $index => $author) { $searchableFields[] = $author; - $searchableFields[] = dlts_solr_remove_accents($author); if ($index == 0) { - //$document->addField('ss_sauthor', dlts_solr_remove_accents(strtolower($author))); $document->addField('ss_sauthor', strtolower(dlts_solr_remove_accents($author))); - $document->addField('iass_author', dlts_solr_remove_accents(strtolower($author))); + $document->addField('iass_author', $author); } $document->addField('sm_author', $author); - $document->addField('tum_author', dlts_solr_remove_accents($author)); - $document->addField('sm_sauthor', strtolower(dlts_solr_remove_accents($author))); } } unset($authors); @@ -441,9 +435,7 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { if (!empty($publishers)) { foreach ($publishers as $publisher) { $document->addField('sm_publisher', $publisher); - $document->addField('tum_publisher', dlts_solr_remove_accents($publisher)); - $document->addField('sm_spublisher', strtolower(dlts_solr_remove_accents($publisher))); - $searchableFields[] = dlts_solr_remove_accents($publisher); + $searchableFields[] = $publisher; } } unset($publishers); @@ -498,11 +490,9 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { /** single-value field */ $publication_location = $wrapper->field_publication_location->value(); if (!empty($publication_location)) { - $searchableFields[] = dlts_solr_remove_accents($publication_location); + $searchableFields[] = $publication_location; $document->addField('ss_publication_location', $publication_location); - $document->addField('ss_spublocation', strtolower(dlts_solr_remove_accents($publication_location))); $document->addField('ss_publocation', $publication_location); // remove this? @kate- when search options are fixed - $document->addField('tus_spublocation', dlts_solr_remove_accents($publication_location)); } unset($publication_location); /** Subject (field_subject) */ @@ -511,12 +501,9 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { if (!empty($subjects)) { foreach ($subjects as $index=>$subject) { $document->addField('sm_subject_label', $subject->name); - $document->addField('sm_ssubject_label', strtolower(dlts_solr_remove_accents($subject->name))); - $document->addField('tum_ssubject_label', strtolower(dlts_solr_remove_accents($subject->name))); - $searchableFields[] = dlts_solr_remove_accents($subject->name); + $searchableFields[] = $subject->name; if ($index == 0) { - $document->addField('ss_ssubject', strtolower(dlts_solr_remove_accents($subject->name))); - $document->addField('iass_subject', strtolower(dlts_solr_remove_accents($subject->name))); + $document->addField('iass_subject', $subject->name); } $document->addField('zm_subject',json_encode(array('name'=>$subject->name,'tid' => $subject->tid, 'vid' => $subject->vid))); } @@ -556,7 +543,6 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { unset($language); /** Single value fields */ - //Remove combining diacritics $document->addField('ss_title', $book_field_title); // Strip HTML Tags $title_sort = strip_tags($book_field_title); @@ -574,7 +560,6 @@ function dlts_solr_index_book(&$document, &$entity, $entity_type, $env_id) { /** Sort fields */ $document->addField('ss_longlabel', $title_sort); $document->addField('iass_longlabel', $title_sort); - $document->addField('tus_longlabel', $title_sort); /** add translations */ dlts_solr_index_book_translations($document, $entity, $entity_type, $env_id, $searchableFields); unset($document->content); diff --git a/modules/dlts_solr/inc/translations.inc b/modules/dlts_solr/inc/translations.inc index 68a68346..61148d60 100755 --- a/modules/dlts_solr/inc/translations.inc +++ b/modules/dlts_solr/inc/translations.inc @@ -15,7 +15,8 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ /** Title (field_title) */ /** single-value field */ $title_long = $wrapper->field_title->value(); - if (isset($entity->solr_multivolume)) { + if(!empty($title_long)) { + if (isset($entity->solr_multivolume)) { $multivolume = $entity->solr_multivolume; $volume = ''; // volume_number_str can be empty, if so, try volume_number @@ -26,17 +27,15 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ $volume = t('Vol.') . ' ' . $multivolume['volume_number']; } $title_long = $title_long . ' ' . $volume; - } + } - $title_long = trim($title_long); + $title_long = trim($title_long); /** Added temporarily to accomodate search options should be removed later-@ekate */ - $document->addField('ss' . $prefix . '_title', dlts_solr_remove_accents(strtolower($title_long))); - $document->addField('ss' . $prefix . '_stitle', dlts_solr_remove_accents($title_long)); - $document->addField('iass' . $prefix . '_longlabel', dlts_solr_remove_accents(strtolower($title_long))); - $document->addField('ss' . $prefix . '_title_long', $title_long); - $document->addField('tus' . $prefix . '_stitle_long', $title_long); - $document->addField('ss' . $prefix . '_stitle_long', dlts_solr_remove_special_cahrs($title_long)); - $searchableFields[] = $title_long; + $document->addField('ss' . $prefix . '_title', $title_long); + $document->addField('ss' . $prefix . '_title_long', $title_long); + $document->addField('iass' . $prefix . '_longlabel', $title_long); + $searchableFields[] = $title_long; + } unset($title_long); /** multi-value field */ dlts_solr_index_book_collection($wrapper->field_collection->value(), $document, $node, $searchableFields); @@ -52,8 +51,7 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ $document->addField('ss' . $prefix . '_sauthor', dlts_solr_remove_accents(strtolower($author))); $document->addField('iass' . $prefix . '_author', strtolower(dlts_solr_remove_accents($author))); } - $document->addField('sm' . $prefix . '_sauthor', strtolower( dlts_solr_remove_special_cahrs($author))); - $document->addField('tum' . $prefix . '_author', $author); + $document->addField('sm' . $prefix . '_author', $author); } } unset($authors); @@ -98,7 +96,6 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ foreach ($publishers as $publisher) { $document->addField('sm' . $prefix . '_publisher', $publisher); $document->addField('sm' . $prefix . '_spublisher', strtolower( dlts_solr_remove_special_cahrs($publisher))); - $document->addField('tum' . $prefix . '_publisher', $publisher); $searchableFields[] = $publisher; } } @@ -110,10 +107,8 @@ function dlts_solr_index_book_translations(&$document, &$entity, $entity_type, $ if (!empty($publication_location)) { $searchableFields[] = $publication_location; $document->addField('ss' . $prefix . '_publication_location', $publication_location); - $document->addField('ss' . $prefix . '_spublocation', strtolower( dlts_solr_remove_special_cahrs($publication_location))); /** add temporarily to accomodate current search options will remove later- @ekate */ $document->addField('ss' . $prefix . '_publocation', $publication_location); - $document->addField('tus' . $prefix . '_publocation', $publication_location); } unset($publication_location); }