I’m trying to implement a search where in addition to the search fields, I have a flag in my contents “prioritize” and if it’s set to true, that result should score higher than an equivalent where the flag is false.
mysql> drop table if exists t; create table t(f text, prio bool); insert into t values(1, 'abc', 1),(2, 'abc', 0); select *, weight() + prio c, prio from t where match('abc') order by c desc;
--------------
drop table if exists t
--------------
Query OK, 0 rows affected (0.005 sec)
--------------
create table t(f text, prio bool)
--------------
Query OK, 0 rows affected (0.004 sec)
--------------
insert into t values(1, 'abc', 1),(2, 'abc', 0)
--------------
Query OK, 2 rows affected (0.001 sec)
--------------
select *, weight() + prio c, prio from t where match('abc') order by c desc
--------------
+------+------+------+------+
| id | f | c | prio |
+------+------+------+------+
| 1 | abc | 1357 | 1 |
| 2 | abc | 1356 | 0 |
+------+------+------+------+
2 rows in set (0.001 sec)
--- 2 out of 2 results in 0ms ---