I have an index for a vocabulary and I have a parent field indexed. When I wanted to index the terms I got this error:

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column 'entity_taxonomy_term_parent' at row 1: INSERT INTO @search_api_db_category (search_api_language, entity_taxonomy_term_name, entity_taxonomy_term_description, entity_taxonomy_term_parent, entity_taxonomy_term_weight, item_id) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => en [:db_insert_placeholder_1] => somename [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => entity:taxonomy_term|13:en )

Seems to me that the Search API cannot properly extract the value of the parent. Second thing I've noticed is that the Search API didn't do any typecasting so this emtpy string, instead of being typecasted to 0 or NULL, is left as is which triggers the error.

Estimated Value and Story Points

This issue was identified as a Beta Blocker for Drupal 8. We sat down and figured out the value proposition and amount of work (story points) for this issue.

Value and Story points are in the scale of fibonacci. Our minimum is 1, our maximum is 21. The higher, the more value or work a certain issue has.

Value : 2
Story Points: 3

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Component: Framework » Database backend

Please be a bit more specific:
- Are you working with the latest sandbox version? If so, why didn't you file the issue in the sandbox's issue queue?
- Please state right away that you are indexing taxonomy terms, not "a vocabulary".
- Does taxonomy term 13 have any parents? If not, then extracting doesn't seem to be the problem.

In any case, thanks for reporting this problem! We'll look into it.

drunken monkey’s picture

Project: Search API » Search API (8.x)
Version: 8.x-1.x-dev »
drunken monkey’s picture

Issue tags: +sprint
alarcombe’s picture

Seems to be reproducible. If you select to index a term's parents the default field type is set to Integer. If you save this then indexing results in the error message above. Set the field type to String and it indexes without error.

I'm not sure yet whether we need to index the term's parent's tids (ie we should get the tid of each parent and index that), or index the term's parent's Name (ie we just need to set the default field type to String). Investigating further unless someone can point me in the right direction.

  • mollux committed b70d5a3 on master
    Issue #2284199 by Mollux : Fixed index errors with empty non text fields...
mollux’s picture

Status: Active » Fixed
Berdir’s picture

The parent is now an entity reference, but they're still not loaded by default...

drunken monkey’s picture

Status: Fixed » Needs review

Just spoke with mollux, he didn't verify that if a parent is actually there, it gets indexed correctly. So we should make sure that this is the case before closing this.
(And maybe add some tests?)

  • mollux committed b70d5a3 on 2349435-seperate-processors-by-stage
    Issue #2284199 by Mollux : Fixed index errors with empty non text fields...
drunken monkey’s picture

Project: Search API (8.x) » Search API
Version: » 8.x-1.x-dev
Component: Database backend » Framework
drunken monkey’s picture

Status: Needs review » Active
Nick_vh’s picture

Issue summary: View changes
Issue tags: +beta blocker
jamescx’s picture

The entity parents do not seem to be indexing at all - all I am getting is NULL values where there should be a term parent; tried both TID and name, both as fulltext and integer/sting.

I'm not entirely clear where I should be looking to give more information to be honest as this has me stumped and have no idea what's going wrong - any pointers?

drunken monkey’s picture

You're right, I could reproduce this now. Thanks for bumping!
It seems like a Core bug, or at least inconsistency: #2695527: Impossible to access entity fields with custom storage via typed data.
For now, I can just propose a patch detecting such fields with custom storage and removing them from the "Add fields" UI.
If you want to index term parents at the moment, it seems your best choice is to write a custom processor that fills the parent field manually (and any related fields of the parents).

drunken monkey’s picture

No progress on the Core bug and we want to finally get to Beta, so let's just exclude term parents for now.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Sure, that makes sense.

  • drunken monkey committed 76cbdff on 8.x-1.x
    Issue #2284199 by drunken monkey: Fixed presence of unindexable "custom...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your feedback, good to hear.
Committed.

Status: Fixed » Closed (fixed)

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