diff --git a/docroot/sites/all/modules/custom/nrf_search/nrf_search.module b/docroot/sites/all/modules/custom/nrf_search/nrf_search.module index 8e95b47..44ce2d9 100644 --- a/docroot/sites/all/modules/custom/nrf_search/nrf_search.module +++ b/docroot/sites/all/modules/custom/nrf_search/nrf_search.module @@ -113,12 +113,20 @@ function nrf_search_entity_update($entity, $type) { if ('synonym' != $type) { return; } + +print_r(array_keys((array)$entity)); // @todo Grab *original* value and pass it too so we delete the old set fully. $target = $entity->field_base_value[LANGUAGE_NONE][0]['value']; $synonyms = array(); foreach ($entity->field_synonyms[LANGUAGE_NONE] as $synonym) { $synonyms[] = $synonym['value']; } + +/* + $orig_synonyms = array(); + if (!empty($entity->original)) { + $target = $entity->original->field_base_value[LANGUAGE_NONE][ +*/ _nrf_search_update_synonym($target, $synonyms); } @@ -137,9 +145,14 @@ function nrf_search_entity_delete($entity, $type) { /** * Update synonym data in Solr. */ -function _nrf_search_update_synonym($target, $synonyms = array()) { +function _nrf_search_update_synonym($target, $synonyms = array(), $orig_synonyms = array()) { $synonyms[] = $target; + // Use synonyms for original if they weren't provided. + if (empty($orig_synonyms)) { + $orig_synonyms = $synonyms; + } + $conditions = array('class' => 'search_api_solr_service', 'enabled' => TRUE); foreach (search_api_server_load_multiple(FALSE, $conditions) as $server) { try { @@ -150,7 +163,7 @@ function _nrf_search_update_synonym($target, $synonyms = array()) { $params = array(); $options = array( 'method' => 'DELETE', - 'data' => drupal_json_encode($synonyms), + 'data' => drupal_json_encode($orig_synonyms), ); try { $connection->makeServletRequest("schema/analysis/synonyms/{$resource}", $params, $options);