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.
Comments
Comment #4
drunken monkeyThanks 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.
Comment #5
pearls commentedThanks @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
Comment #6
drunken monkeyGreat to hear, thanks for testing!
Merged.