Не повторяется на последней версии:
mysql> drop table if exists t; create table t(f text); insert into t values(1, 'iphone 17'),(2, 'iphone 17 pro max'),(3, 'iphone'); select *, weight(), packedfactors() from t where match('iphone') option ranker=expr('1');
--------------
drop table if exists t
--------------
Query OK, 0 rows affected (0.03 sec)
--------------
create table t(f text)
--------------
Query OK, 0 rows affected (0.02 sec)
--------------
insert into t values(1, 'iphone 17'),(2, 'iphone 17 pro max'),(3, 'iphone')
--------------
Query OK, 3 rows affected (0.01 sec)
--------------
select *, weight(), packedfactors() from t where match('iphone') option ranker=expr('1')
--------------
+------+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | f | weight() | packedfactors() |
+------+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | iphone 17 | 1 | bm25=319, bm25a=0.19519952, field_mask=1, doc_word_count=1, field0=(lcs=1, hit_count=1, word_count=1, tf_idf=-0.39624062, min_idf=-0.39624062, max_idf=-0.39624062, sum_idf=-0.39624062, min_hit_pos=1, min_best_span_pos=1, exact_hit=0, max_window_hits=1, min_gaps=0, exact_order=1, lccs=1, wlccs=-0.39624062, atc=0.000000), word0=(tf=1, idf=-0.39624062) |
| 2 | iphone 17 pro max | 1 | bm25=319, bm25a=0.19519952, field_mask=1, doc_word_count=1, field0=(lcs=1, hit_count=1, word_count=1, tf_idf=-0.39624062, min_idf=-0.39624062, max_idf=-0.39624062, sum_idf=-0.39624062, min_hit_pos=1, min_best_span_pos=1, exact_hit=0, max_window_hits=1, min_gaps=0, exact_order=1, lccs=1, wlccs=-0.39624062, atc=0.000000), word0=(tf=1, idf=-0.39624062) |
| 3 | iphone | 1 | bm25=319, bm25a=0.19519952, field_mask=1, doc_word_count=1, field0=(lcs=1, hit_count=1, word_count=1, tf_idf=-0.39624062, min_idf=-0.39624062, max_idf=-0.39624062, sum_idf=-0.39624062, min_hit_pos=1, min_best_span_pos=1, exact_hit=1, max_window_hits=1, min_gaps=0, exact_order=1, lccs=1, wlccs=-0.39624062, atc=0.000000), word0=(tf=1, idf=-0.39624062) |
+------+-------------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)
--- 3 out of 3 results in 0ms ---
У последнего результата, как видно, exact_hit=1
Из-за этого тот же встроенный ранкер sph04 выдает мне одинаковый вес всем трем документам при запросе “iphone”.
select *, weight(), packedfactors() from t where match('iphone') option ranker=sph04
--------------
+------+-------------------+----------+-----------------+
| id | f | weight() | packedfactors() |
+------+-------------------+----------+-----------------+
| 3 | iphone | 7319 | |
| 1 | iphone 17 | 6319 | |
| 2 | iphone 17 pro max | 6319 | |
+------+-------------------+----------+-----------------+
3 rows in set (0.01 sec)
--- 3 out of 3 results in 1ms ---