Problem/Motivation
When trying to index content, an error is shown and the logs give some more details:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_name' in 'field list': INSERT INTO @search_api_db_default_index_text (item_id, field_name, word, score) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => entity:node/1:en [:db_insert_placeholder_1] => entity:node/title [:db_insert_placeholder_2] => test [:db_insert_placeholder_3] => 8000 )
Proposed resolution
Find the faulty SQL query, fix it, submit patch, review and commit patch.
Remaining tasks
All of them.
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #1
christianadamski commentedI can confirm this behavior on a blank Drupal 8 using the search_api_db_defaults.
The
search_api_db_default_index_texttable will just have two columns "item_id" and "value".However: when uncommenting everything pointing to
entity/node:titleandrendered_iteminsearch_api.index.default_index.ymlandsearch_api.server.default_server.yml, the module will install fine and work. After that, I could successfully step by step enable the other feature including setting the fields to fulltext and thesearch_api_db_default_index_texttable will be created with the correct 4 columns, including the "field_name" that caused the Exception in the ops post.Comment #2
drunken monkeyDoes this maybe help?
Comment #4
LKS90 commentedYes, it solves the problem described in the issue summary. Here is a test fix for the fix you did, to get the tests green again.
I also wrote a test for the Database defaults, I'll post it in a separate comment (it's complicated :P).
Comment #5
LKS90 commentedHere is the test I was talking about. The Search API Database defaults submodule depends on configuration from the Standard profile, therefore this test uses it. It takes some time to install when using the standard profile, so I don't think this test should be added to the automated testing.
Another reason why this test shouldn't be committed (yet): There are still issues related to the view_mode when indexing/creating new content, I'll create a separate issue to fix the database defaults submodule.
Edit: The issues I mentioned are already known/a patch might be committed soon: #2473717: Add support for per-bundle view modes in the rendered entity processor.
Comment #8
drunken monkeyI spotted another issue here, leading to indexing errors for nodes that have more than one tag assigned: the database backend incorrectly handled the case where the table is already saved in the server configuration but has not been created yet (because the config is imported). In this case, the field-specific table had a primary key only containing
item_id, notitem_id, value– leading to exceptions for any multi-valued fields on items.Should also be fixed in the attached patch, please test/review!
Also, thanks a lot for fixing the test fails and posting a new test for this! That's exactly what I wanted to suggest, but you already created it, awesome!
The test could probably be optimized a lot by just installing the bits that are needed, not the complete "Standard" profile, but since the complete build still didn't even take 2.5 minutes, I think it would be acceptable to still add it like this, maybe with an
@todocomment pointing out the possible performance improvement.In any case, though, please post this patch in a new issue, I think here we can commit soon and shouldn't have to wait for that test.
Comment #9
drunken monkeyComment #11
LKS90 commentedShould we update this?
It's a minor nitpick, string is text after all :P.
Couldn't reproduce the test fail which happened on the Jenkins build, I'd say this is good to go.
Comment #12
drunken monkeySee #2565567: Inconsistent patch test results for old and new testbot for that. I'm just ignoring them for now.
Fixed the test message (thanks for spotting!) and committed it.
Thanks again for all of your work here!
Comment #15
PatchRanger commentedI had the same symptoms as in original issue at Drupal 7.41:
search_api_db SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_name' in 'field list'Let me re-open the issue for 7.x - looks like it should be backported.
Comment #16
drunken monkeyFrom what I can see, this has to be a different issue, even if the error message is the same. From the code it doesn't look like this bug could also exist in the D7 version.
Please create a new issue in the search_api_db issue queue.