public function getSuggestedLinksForRegistryObject(_registry_object $registry_object, $start, $rows)
 {
     // First, get published records with the same identifier as us
     // Note: whilst we can use SOLR to get the linked-to records,
     //       we shouldn't use SOLR to get our own information, as
     //       this would mean that DRAFT requests fail (drafts NOT
     // 		 in SOLR index).
     $suggestions = array();
     $sxml = $registry_object->getSimpleXML();
     if ($sxml->registryObject) {
         $sxml = $sxml->registryObject;
     }
     // Subject matches
     $my_subjects = array();
     if ($sxml->{strtolower($registry_object->class)}->subject) {
         foreach ($sxml->{strtolower($registry_object->class)}->subject as $subject) {
             $my_subjects[] = (string) removeBadValue($subject);
         }
     }
     if (count($my_subjects) == 0) {
         return $suggestions;
     }
     if (sizeof($my_subjects) > 0) {
         $subject_search_query = join('" OR subject_value_resolved:"', $my_subjects);
         $subject_search_query = "(subject_value_resolved:\"" . $subject_search_query . "\")";
     }
     // But exclude already related objects
     $my_relationships = array_map(function ($elt) {
         return $elt;
     }, $registry_object->getRelatedKeys());
     $my_relationships[] = $registry_object->key;
     $relationship_search_query = '';
     if (sizeof($my_relationships) > 0) {
         $relationship_search_query = join('","', $my_relationships);
         $relationship_search_query = '-key:("' . $relationship_search_query . '")';
     }
     $query = $relationship_search_query;
     if ($subject_search_query != '') {
         $query .= ' AND ' . $subject_search_query;
     }
     $suggestions = $this->getSuggestionsBySolrQuery($query, $start, $rows);
     if (sizeof($suggestions) > 0) {
         $suggestions['values'] = $my_subjects;
     }
     return $suggestions;
 }
 /**
  * Suggest Records based on subject_value_unresolved value
  * from the local SOLR core.
  * Rely on Solr's score.
  * @return array suggested_records
  */
 function suggest()
 {
     //Get subjects from the XML
     $suggestions = array();
     $sxml = $this->ro->getSimpleXML();
     if ($sxml->registryObject) {
         $sxml = $sxml->registryObject;
     }
     // Subject matches
     $my_subjects = array();
     if ($sxml->{strtolower($this->ro->class)}->subject) {
         foreach ($sxml->{strtolower($this->ro->class)}->subject as $subject) {
             $my_subjects[] = (string) removeBadValue($subject);
         }
     }
     //construct the query stirng
     $str = '';
     foreach ($my_subjects as $s) {
         $str .= 'subject_value_unresolved:(' . $s . ') ';
     }
     if ($str != '') {
         //call SOLR library
         $maxRows = 50;
         $ci =& get_instance();
         $ci->load->library('solr');
         $ci->solr->init();
         $ci->solr->init()->setOpt('q', $str)->setOpt('rows', $maxRows)->setOpt('fl', 'id,key,slug,title,score')->setOpt('fq', '-id:' . $this->ro->id)->setOpt('fq', 'class:collection')->setOpt('defType', 'edismax');
         $result = $ci->solr->executeSearch(true);
         if ($result['response']['numFound'] > 0) {
             $maxScore = floatval($result['response']['maxScore']);
             $intScore = 0;
             foreach ($result['response']['docs'] as $doc) {
                 $doc['score'] = $doc['score'] / $maxScore * (1 - $intScore / $maxRows);
                 $intScore++;
                 $doc['RDAUrl'] = portal_url($doc['slug'] . '/' . $doc['id']);
                 $suggestions[] = $doc;
             }
         }
     }
     return $suggestions;
 }