You are here

function hook_apachesolr_entity_info_alter in Apache Solr Search 8

Same name and namespace in other branches
  1. 6.3 apachesolr.api.php \hook_apachesolr_entity_info_alter()
  2. 7 apachesolr.api.php \hook_apachesolr_entity_info_alter()

Add information to index other entities. There are some modules in http://drupal.org that can give a good example of custom entity indexing such as apachesolr_user, apachesolr_term

Parameters

array $entity_info:

1 function implements hook_apachesolr_entity_info_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

apachesolr_search_apachesolr_entity_info_alter in ./apachesolr_search.module
Implements hook_apachesolr_entity_info_alter().
1 invocation of hook_apachesolr_entity_info_alter()
apachesolr_entity_info_alter in ./apachesolr.module
Implements hook_entity_info_alter().

File

./apachesolr.api.php, line 276
Exposed Hooks in 7.x:

Code

function hook_apachesolr_entity_info_alter(array &$entity_info) {

  // REQUIRED VALUES
  // myentity should be replaced with user/node/custom entity
  $entity_info['node'] = array();

  // Set this entity as indexable
  $entity_info['node']['indexable'] = TRUE;

  // Validate each entity if it can be indexed or not. Multiple callbacks are
  // allowed. If one of them returns false it won't be indexed
  $entity_info['node']['status callback'][] = 'apachesolr_index_node_status_callback';

  // Build up a custom document.
  $entity_info['node']['document callback'][] = 'apachesolr_index_node_solr_document';

  // What to do when a reindex is issued. Most probably this will reset all the
  // items in the index_table
  $entity_info['node']['reindex callback'] = 'apachesolr_index_node_solr_reindex';

  // OPTIONAL VALUES
  // Index in a separate table? Useful for huge datasets.
  $entity_info['node']['index_table'] = 'apachesolr_index_entities_node';

  // Execute custom callback on each cron run.
  // See apachesolr_index_node_check_table
  $entity_info['node']['cron_check'] = 'apachesolr_index_node_check_table';

  // Specific output processing for the results
  $entity_info['node']['result callback'] = 'apachesolr_search_node_result';

  // BUNDLE SPECIFIC OVERRIDES
  // The following can be overridden on a per-bundle basis.
  // The bundle-specific settings will take precedence over the entity settings.
  $entity_info['node']['bundles']['page']['apachesolr']['result callback'] = 'apachesolr_search_node_result';
  $entity_info['node']['bundles']['page']['apachesolr']['status callback'][] = 'apachesolr_index_node_status_callback';
  $entity_info['node']['bundles']['page']['apachesolr']['document callback'][] = 'apachesolr_index_node_solr_document';
}