Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When a node is deleted or unpublished, it gets removed from Solr index by the function apachesolr_index_delete_entity_from_index(). However the translated documents in Solr are not being removed.
This is because the Solr query in apachesolr_index_delete_entity_from_index() does not take into account language:
$document_id = apachesolr_document_id($entity_id, $entity_type);
$query = "id:\"$document_id\" OR sm_parent_document_id:\"$document_id\"";
$solr->deleteByQuery($query);
The solution is very simple, add the original document id to the translated documents, in the field sm_parent_document_id.
I will add a patch for this.
Thank you very much,
Maarten Steurs
Webfordreams
Comment | File | Size | Author |
---|---|---|---|
#4 | apachesolr_multilingual-remove_translation_documents-2195363.patch | 771 bytes | webfordreams |
Comments
Comment #1
webfordreams CreditAttribution: webfordreams commentedComment #2
webfordreams CreditAttribution: webfordreams commentedComment #3
webfordreams CreditAttribution: webfordreams commentedComment #4
webfordreams CreditAttribution: webfordreams commentedComment #5
mkalkbrennerI had a look at the code. The problem you described only occurs in combination with entity translation. Your patch fixes the issue for entity translation but might break node translation aka content translation.
When you're using node translation nodes and their translations could be unpublished and deleted independently.
To judge your patch I need to find out more details about sm_parent_document_id and why it has been introduced. Beside the delete queries I don't find any occurrence of this field in the apachesolr modules.
Comment #6
mkalkbrennersm_parent_document_id has been introduced by #1515822: Support notion of parent entity for derived documents and seems to be the right choice for our needs.
Comment #7
mkalkbrennerPatch works. Committed http://drupalcode.org/project/apachesolr_multilingual.git/commit/ccf50fd
Comment #8
mkalkbrennerWe made a small mistake: values for sm_* fields (String Multiple) need to be arrays. I committed a fix:
http://drupalcode.org/project/apachesolr_multilingual.git/commit/2601826