Modules used: search-api-solr 7.x-1.0-rc2, entity-7.x-1.0-rc3, search-api-7.x-1.1
Repeatable: Always

When values is set to unlimited on the body of a content type, and "The main body text » Text" is selected for indexing, the following error is thrown and the body field is missing in the index:
Notice: Undefined index: value in entity_metadata_field_text_get() in entity/modules/callbacks.inc

Temporarily setting the content type to only allow one value, allows the node to be indexed correctly (for delta 0), the error is not thrown.

Expected behavior: Iterate through all body values when indexing. Though, only indexing delta 0 and ignoring the rest would already be a significant improvement in comparison to the missing body.

#1426144: When selecting fields to index add option to choose the delta for multivalued fields is related to this, but requests a specific delta rather than all.

Comments

drunken monkey’s picture

Project: Search API » Entity API
Version: 7.x-1.1 » 7.x-1.x-dev
Component: Framework » Core integration

Thanks for reporting!

Seems like an Entity API bug. It seems they don't respect the cardinality of text fields when specifying the type of properties. At least that's what it looks like to me.
In any case, I can reproduce this.

Moving the issue …

grahl’s picture

Version: 7.x-1.x-dev » 7.x-1.0
Status: Active » Needs work
StatusFileSize
new757 bytes

Attached is a patch which fixes the problem. It occurs due to the fact that with cardinality > 1 on the generic body field the contents of the $item array is wrapped within another array. So $item['value'] is actually $item[0]['value'].

Since the structure within the nested array is already as expected, ideally the input passed entity_metadata_field_text_get() would get fixed, rather than needing this workaround.

Marcus 78’s picture

Same error but patch doesnt help at all

grahl’s picture

StatusFileSize
new644 bytes

Patch update avoids an E_NOTICE, not sure if the patch has a fundamental flaw or why it doesn't work for #3.

grahl’s picture

Issue summary: View changes

Fixed the link to other issue

valderama’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new562 bytes

This bug is still valid in current dev of entity. It makes indexing body fields with search_api impossible if the cardinality is not 1.

I have attached a patch, which changes the property type to a list, if cardinality is not 1.

Please review.

mfb’s picture

Status: Needs review » Reviewed & tested by the community

Looks good and patch is working as far as I can tell; haven't seen any regressions yet.

fago’s picture

Good fix, I agree it should be fine as it the setting is shared across all field instances. The comment has a typo though - I fix that on commit.

  • fago committed 2563769 on 7.x-1.x authored by valderama
    Issue #1621002 by grahl, valderama, mfb, fago: Cardinality breaks node...

  • fago committed 435f1e6 on 7.x-1.x authored by valderama
    Issue #1621002 by grahl, valderama, mfb, fago: Fix typo in comment of...
fago’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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