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)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BR0kEN created an issue. See original summary.

BR0kEN’s picture

drunken monkey’s picture

Thanks 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!

drunken monkey’s picture

D7 has exactly the same problem. Weird no-one noticed it there before.

BR0kEN’s picture

Sounds reasonable, nice changes @drunken.

BR0kEN’s picture

Status: Needs review » Reviewed & tested by the community

  • drunken monkey committed 97db322 on 8.x-1.x authored by BR0kEN
    Issue #2844192 by BR0kEN, drunken monkey: Fixed failure in DB backend...
drunken monkey’s picture

Project: Search API » Search API Database Search
Version: 8.x-1.x-dev » 7.x-1.x-dev
Component: Database backend » Code
Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs backport to D7

Great to hear, thanks for reviewing!
Committed.
Moving to D7 version.

drunken monkey’s picture

  • drunken monkey committed 2daa017 on 7.x-1.x
    Issue #2844192 by drunken monkey: Fixed switching field boost from zero...
drunken monkey’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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