Trying to create a field of type list<text>, triggers a Unknown field type text. Database search module might be out of sync with Search API. exception in the database engine.

This is because ->fieldsUpdated() doesn't properly extract the inner type when taking the decision of what to do.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Damien Tournoud’s picture

Status: Active » Needs review
FileSize
2.35 KB

This fixes it, and probably a couple of related bugs.

I see no obvious way of extending the automated tests to cover this, so I'll let it as an exercise for the reader.

drunken monkey’s picture

Status: Needs review » Needs work
+++ b/contrib/search_api_db/service.inc
@@ -246,17 +248,17 @@ class SearchApiDbService extends SearchApiAbstractService {
         }
       }
-      elseif (!$reindex && $new_type == 'text' && $field['boost'] != $new_fields[$name]['boost']) {
+      elseif (!$reindex && $new_inner_type == 'text' && $field['boost'] != $new_fields[$name]['boost']) {
         $multiplier = $new_fields[$name]['boost'] / $field['boost'];

Unless I'm mistaken, $new_inner_type won't be set here, as you set that inside of the above if block. You could just use seach_api_is_text_type($new_type) instead – or extract the types outside of the blocks,of course.

Otherwise, the patch looks good, thanks a lot for spotting this!

Damien Tournoud’s picture

Status: Needs work » Needs review
FileSize
2.44 KB

Good catch. Here is a fixed version.

drunken monkey’s picture

Title: DB engine doesn't support list<text> » Fix update of field settings for DB backend
FileSize
2.44 KB

Patch looks good, but I think there are still cases where this wouldn't work – mostly, when the list level of a field type changes (which might happen e.g. with data alterations, or when switching a field from single-valued to multi-valued). Please see if the attached patch works for you, too.

Damien Tournoud’s picture

Ok, but this encovered another issue: _search_api_admin_get_fields() never updates the nesting level of a known field...

drunken monkey’s picture

Title: Fix update of field settings for DB backend » Fix update of field type settings for DB backend and index
Status: Needs review » Fixed

Ok, but this encovered another issue: _search_api_admin_get_fields() never updates the nesting level of a known field...

Wow, awesome that you spotted and fixed that!
Patch looks good now and also seems to work – committed, thanks again!

Status: Fixed » Closed (fixed)

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