Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
titleSolr Copyfield
collapsetrue
<copyField source="id" dest="PID"/>

In older versions of Solr you can copy the id to the PID and have the PID as the uniqueKey.  In newer versions of Solr you may not be able to copy the id to PID (newer versions don't seem to let you use the uniqueKey as a destination for a copyField).  In that case it may be easier to modify the GSearch xslt to create an id field instead of PID and use it as the uniqueKey in your schema.

Save the schema.xml file and restart Solr.  After the restart you should be able to view solr at http://ip:port/solr. 

Apache Solr Module

Once you have Solr configured properly and restarted you can configure the Apache Solr module in your Drupal site configuration section (see https://drupal.org/project/apachesolr for more information).  Basically you just download it and enable as you would any other module.  You've already modified the schema.xml so you don't need to do anything with schemal.xml.

At this point if everything is configured properly you should see some Drupal content in your solr index, if you don't you may have to wait for cron to run or you can force the module to index content from the modules config interface (admin/config/search/apachesolr).

Modify Islandora search results

Islandora will not know how to properly display a result created from a Drupal node so you will either have to add a custom Islandora Solr display profile or use the theme layer to preprocess the results, there are examples of creating a custom display profile in the islandora_solr_module.

To modify results in your theme you could create a function called themename_preprocess_islandora_solr(&$variables). In this function you could check for a field that will only exist with drupal content, for instance bundle_name, and if it is not empty you could modify the thumbnail and the url used to link back to the content.

For example if you are using the bartik theme you could do something like:

Code Block
languagephp
titletheme_preprocess_islandora_solr
collapsetrue
function bartik_preprocess_islandora_solr(&$variables) {
	$results = &$variables['results'];
		foreach ($results as &$result) {
			if (!empty($result['solr_doc']['bundle_name'])) {
			$path = url('http://aurltothethumbnail'); //could check bundle for type and link to thumbnail for each type
			$options = array('html' => TRUE);
			$options['attributes']['title'] = $result['solr_doc']['label'];
			$image = theme('image', array('path' => $path));
			$key['thumbnail'] = l($image, $result['solr_doc']['url']['value'], $options);
		}
	}
}


Modifying the results by using a theme_preprocss hook is probably the easist way to modify your results but is probably also the most brittle. For instance if you change your theme your results page may break.

 

Content by Label
showLabelsfalse
max5
spacesISLANDORA713
sortmodified
showSpacefalse
reversetrue
typepage
labelssolr search