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

Comments

msteurs’s picture

msteurs’s picture

Issue summary: View changes
msteurs’s picture

msteurs’s picture

mkalkbrenner’s picture

Status: Active » Needs work

I 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.

mkalkbrenner’s picture

Title: Remove translation documents from Index when removing original document. » Entity Translation: Remove translation documents from Index when removing original document.
Assigned: Unassigned » mkalkbrenner

sm_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.

mkalkbrenner’s picture

Status: Needs work » Fixed
mkalkbrenner’s picture

We 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

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

  • Commit ccf50fd on 7.x-1.x, 6.x-3.x authored by msteurs, committed by mkalkbrenner:
    Issue #2195363 by msteurs: Entity Translation: Remove translation...