When indexing content, the apache solr teaser is created using the node teaser (if exists).
Right now, the Apache Solr Search assumes that the body field have a language and by default the field language is the node language. As far as I know, the only module that makes use of field language is Entity Translation so I created a patch to check if this is an active module and use a field with a language, otherwise LANGUAGE_NONE must be used as this is the default way of work.

Please comment.
Cheers

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rutiolma’s picture

The patch

Status: Needs review » Needs work

The last submitted patch, 1: apachesolr-indexing_teaser-2315173-1.diff, failed testing.

rutiolma’s picture

FileSize
1.18 KB
stefan.r’s picture

Version: 7.x-1.6 » 7.x-1.x-dev
Status: Needs work » Needs review
FileSize
913 bytes

@rmarques, Bart D asked me to have a look at this and a patch like this would indeed be needed in case the body field language doesn't match the node language.

Does the attached patch work for you too? It gets the body field language directly, instead of "guessing" what it is ;)

stefan.r’s picture

Title: Indexing node teaser on a non-translated field » Node teasers aren't indexed if body field language is different than node language

Status: Needs review » Needs work

The last submitted patch, 4: apachesolr-indexing_teaser-2315173-4.patch, failed testing.

Status: Needs work » Needs review
Nick_vh’s picture

Looks good to me. So this makes sure that we get the teaser in the default language of the body field? And this only happens when there is no active node teaser. Is there a similar issue with the node teaser if it does exist?

stefan.r’s picture

Thanks @Nick_vh.

That comment about "no active node teaser" was added in #2012244: In Drupal 7, using short summary in the teaser, I think it refers to $node->teaser not existing but that property never exists in Drupal 7 anyway. Or maybe it refers to the utf8_truncate() a few lines down (which is beyond the scope of this patch).

As to any similar issues, there's the links in comment #5 of this issue, comment #9 in #1178580: PHP notices with [node:summary], [node:body], or [comment:body] if there is no body field or language mismatch and the patch in #1241334: Auto settings for Metatags Quick.

stefan.r’s picture

While we're changing this anyway, merging in #2297243: Teaser is empty when indexing translated content seems appropriate, as well as using a clearer variable name as per #1216094: We call too many things 'language', clean that up :)

rutiolma’s picture

Thank you for your input Stefan, your patch work like a charm.

Nick_vh’s picture

Status: Needs review » Reviewed & tested by the community

ok, good to go

stefan.r’s picture

can we get this committed? :)

japerry’s picture

Status: Reviewed & tested by the community » Fixed

  • japerry committed a49f42d on 7.x-1.x authored by stefan.r
    Issue #2315173 by stefan.r, rutiolma: Node teasers aren't indexed if...

Status: Fixed » Closed (fixed)

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