laravel-scout-mysql-driver icon indicating copy to clipboard operation
laravel-scout-mysql-driver copied to clipboard

Append score or filter on score?

Open ADRDev opened this issue 7 years ago • 4 comments

Is there any way to include or filter on the actual score?

MATCH(contents) AGAINST("TEST STRING" IN NATURAL LANGUAGE MODE)

from the WHERE clause can be repeated in the SELECT with an alias to get the score (this has no overhead according to MySQL docs)

MATCH(contents) AGAINST("TEST STRING" IN NATURAL LANGUAGE MODE) AS score

which also allows you to add something like "WHERE score > 2"

I tried looking through the code, but I can't figure out how to get to the QueryBuilder instance (for addSelect() method), but it seems Scout Builder doesn't expose this.

Any thoughts?

edit: Just want to add, that the main issue here is that all rows are always returned even ones that have a score of 0. This is not ideal.

ADRDev avatar Jul 31 '17 15:07 ADRDev

or order by score

veneliniliev avatar Aug 18 '17 09:08 veneliniliev

It already orders by score, it just doesn't include it.

ADRDev avatar Aug 18 '17 16:08 ADRDev

Nothing more on this?? I'd also like to be able to filter out if score < x.

spaceSquid avatar Jun 12 '19 14:06 spaceSquid

any solution yet? I am facing same problem here.

hirokku avatar Jul 30 '20 23:07 hirokku