Problem/Motivation

The negative values field can not be indexed.

If you have a weight(number) field used for "number-field-boost-settings( Aggregation - maximum) " and there is a negative value in these fields, the index does not work and gives an error.

SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'score' at row 1: INSERT INTO "dr_search_api_db_default_user_index_text" ("item_id", "field_test", "word", "score") 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, :db_insert_placeholder_6, :db_insert_placeholder_7), (:db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11); Array ( [:db_insert_placeholder_0] => entity:user/40:tr [:db_insert_placeholder_1] => rendered_item [:db_insert_placeholder_2] =>

Any idea, please. Thanks

Note:
By the way, when importing the configuration to a new site with an empty database, the search API gives an error about this weight field.

Issue fork search_api-3484686

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pearls created an issue. See original summary.

drunken monkey made their first commit to this issue’s fork.

drunken monkey’s picture

Title: Support: Indexable negative number » Error when trying to boost on numeric field with negative value
Component: General code » Plugins
Category: Support request » Bug report
Status: Active » Needs review
Related issues: +#3485260: Deprecate negative item scores/boosts

Thanks for reporting this issue!
I can immediately see the problem: While we always assume an item’s boost (or score) value is non-negative, there is nothing in the code actually ensuring this.
The fix is pretty simple for the “Number field-based boosting” – we even already have it there for date fields, we just didn’t think to also apply this for general numeric fields.
Created an MR for fixing this, please test/review!

I also created #3485260: Deprecate negative item scores/boosts as a follow-up to officially declare and verify that boosts cannot be negative.

pearls’s picture

Thanks @drunken monkey.
Please, confirm me if I need both MR(184-185).
Tested. I used both MR and it worked. It indexed without any warning/error.
+1 for RTBC

drunken monkey’s picture

Status: Needs review » Fixed

Great to hear, thanks for testing!
Merged.

  • drunken monkey committed ef98cf5c on 8.x-1.x
    Issue #3484686 by drunken monkey: Fixed error when trying to boost on...

Status: Fixed » Closed (fixed)

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