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
Comment | File | Size | Author |
---|---|---|---|
#15 | 2284199-15--indexing_term_parents.patch | 799 bytes | drunken monkey |
|
Comments
Comment #1
drunken monkeyPlease 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.
Comment #2
drunken monkeyComment #3
drunken monkeyComment #4
alarcombe CreditAttribution: alarcombe commentedSeems 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.
Comment #6
mollux CreditAttribution: mollux commentedComment #7
BerdirThe parent is now an entity reference, but they're still not loaded by default...
Comment #8
drunken monkeyJust 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?)
Comment #10
drunken monkeyComment #11
drunken monkeyComment #12
Nick_vhComment #13
jamescx CreditAttribution: jamescx commentedThe 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?
Comment #14
drunken monkeyYou'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).Comment #15
drunken monkeyNo progress on the Core bug and we want to finally get to Beta, so let's just exclude term parents for now.
Comment #16
borisson_Sure, that makes sense.
Comment #18
drunken monkeyThanks for your feedback, good to hear.
Committed.