Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When you set boost
to 0.0
and then change it for another value, 1.0
for instance then reindexing will be failed with the following errors:
First - division by zero.
Warning: Division by zero in Drupal\search_api_db\Plugin\search_api\backend\Database->fieldsUpdated() (line 926 of /var/www/docroot/profiles/pp/modules/contrib/search_api/modules/search_api_db/src/Plugin/search_api/backend/Database.php)
Second - invalid database expression.
Drupal\search_api\SearchApiException: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'INF': UPDATE {search_api_db_content_text_1} SET score=score * :mult WHERE field_name = :db_condition_placeholder_0; Array ( [:mult] => INF [:db_condition_placeholder_0] => title ) in Drupal\search_api_db\Plugin\search_api\backend\Database->fieldsUpdated() (line 1033 of /var/www/docroot/profiles/pp/modules/contrib/search_api/modules/search_api_db/src/Plugin/search_api/backend/Database.php)
Third - exception and process termination.
Drupal\search_api\SearchApiException while trying to index items on index Content: Could not index items on index 'Content' because pending server tasks could not be executed. in Drupal\search_api\Entity\Server->indexItems() (line 335 of /var/www/docroot/profiles/pp/modules/contrib/search_api/src/Entity/Server.php)
Comment | File | Size | Author |
---|---|---|---|
#9 | 2844192-4--search_api_db--D7--db_backend_update_zero_boost.patch | 1.36 KB | drunken monkey |
|
Comments
Comment #2
BR0kENComment #3
drunken monkeyThanks for reporting this problem! You're right, I didn't take boosts of 0 into account there.
However, if the boost was 0 previously, all indexed scores will be 0, too, so the UPDATE query will be useless. We can't really avoid re-indexing in that case.
Please see/review/test the attached patch!
Comment #4
drunken monkeyD7 has exactly the same problem. Weird no-one noticed it there before.
Comment #5
BR0kENSounds reasonable, nice changes @drunken.
Comment #6
BR0kENComment #8
drunken monkeyGreat to hear, thanks for reviewing!
Committed.
Moving to D7 version.
Comment #9
drunken monkeyRe-attaching D7 patch to trigger test bot.
Comment #11
drunken monkeyCommitted.