When an entity is saved / updated, only the current language index item is updated for that entity_id. This results in non-translatable fields becoming out of sync between languages. For example, suppose you have

  • A multilingual site (English and French) - set to update items immediately
  • A simple node index
  • A view using the index, showing only "promoted" nodes
  • A node (nid:1) with a french translation

Now suppose you edited that node while on the English site and changed the "promote" field to 1. The english entry in the index will have the correct value, but the french entry won't. Here's a sample xml search result from a solr implementation (I removed non-pertinent fields for brevity):

<response>
  <result name="response" numFound="2" start="0">
    <doc>
      <bool name="bs_promote">false</bool>
      <str name="content">Ju Suis en Français</str>
      <str name="hash">jkcc5w</str>
      <str name="id">jkcc5w-node_index-fr_1</str>
      <str name="index_id">node_index</str>
      <str name="item_id">fr_1</str>
      <str name="ss_field_colour">Noir</str>
    </doc>
    <doc>
      <bool name="bs_promote">true</bool>
      <str name="content">I am in English</str>
      <str name="hash">jkcc5w</str>
      <str name="id">jkcc5w-node_index-en_1</str>
      <str name="index_id">node_index</str>
      <str name="item_id">en_1</str>
      <str name="ss_field_colour">Black</str>
    </doc>
  </result>
</response>

Now, if you were visit your hypothetical view (mentioned above) on the English site, it will correctly show us node 1, but if you visit it on the french site, it won't list the node.

Note that I have also tested this with an actual non-translatable field as well (as opposed to a node property) and the problem is the same.

The solution I would propose for this is to update all indexed languages on entity_update. There is a patch in Comment #4 of #2429539: When a node is updated, it is removed from searches' results until the next cron run. that adds this functionality. I'm hesitant to post it here, however, so as not to take credit from the original Author. Also, the issue he is fixing is technically different than mine (although the solution is the same).

I'd be interested to know if other people are having this same issue. It seemed quite odd to me that anyone else using this module wouldn't have noticed it. I don't think the example I gave wasn't especially unique, but I could be wrong...

Thanks!
drclaw

Comments

drclaw created an issue. See original summary.

drclaw’s picture

Issue summary: View changes
thepanz’s picture

Status: Active » Needs review
StatusFileSize
new3.26 KB

Patch moved to this issue from #2429539: When a node is updated, it is removed from searches' results until the next cron run..

Needs review: should this behavior be controlled by a setting or this (related translations are automatically re-indexed) is the expected one?

das-peter’s picture

Just stumbled across another scenario in which this issue hit me.
We're use revision_scheduler to schedule the publication of content.
Content translated with entity translation was only updated in the source language version when the node is published even thought there were translations.
The attached patch fixed the problem.

Found following coding standard nitpicks but I'm tempted to RTBC this.

  1. +++ b/search_api_et.module
    @@ -229,8 +229,24 @@ function search_api_et_entity_update($entity, $entity_type) {
    +    // This Entity is has changed, thus we'd like to propagate the changes also
    

    Typo: "This Entity has changed..."

  2. +++ b/search_api_et.module
    @@ -229,8 +229,24 @@ function search_api_et_entity_update($entity, $entity_type) {
    +    // to the related translations to keep up to date their non-translatable fields.
    

    Exceeds the 80 char limit.

  3. +++ b/search_api_et.module
    @@ -229,8 +229,24 @@ function search_api_et_entity_update($entity, $entity_type) {
    +    $item_ids_language = array_keys(array_flip($item_ids_language ));
    

    There should be no white space before a closing ")"

  4. +++ b/search_api_et.module
    @@ -342,6 +358,27 @@ function search_api_et_multilingual_settings_changed() {
    + * @param array $entity_types
    + *    The entity types to filter from.
    + * @return SearchApiIndex[]|null
    

    Separate the @param and @return sections by a blank line.

thepanz’s picture

Thanks das-peter, which tool did you use to get the checks?
I am a new co-maintainer of this module and I'd like to push it to a new release soon :)

thepanz’s picture

Patch rerolled against latest 7.x-2.x release.
Code cleanup and optimizations (do not over-remove/insert items: let search_api_track_item_change() function deal with them).

  • thePanz committed a7bddce on 7.x-2.x
    Issue #2563439 by thePanz, drclaw, das-peter: Fields that aren't...
thepanz’s picture

Status: Needs review » Fixed

Committed.

das-peter’s picture

@thePanz The coding standards sniffer is part of the Coder module. Here's the documentation: https://www.drupal.org/node/1419980
You can integrate it in a lot of different IDE's so that you'll get hints as you type :)

Status: Fixed » Closed (fixed)

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