yabhq / laravel-scout-mysql-driver

Laravel Scout MySQL Driver
MIT License
522 stars 113 forks source link

Append score or filter on score? #34

Open ADRDev opened 7 years ago

ADRDev commented 7 years ago

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.

veneliniliev commented 7 years ago

or order by score

ADRDev commented 7 years ago

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

spaceSquid commented 5 years ago

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

hirokku commented 4 years ago

any solution yet? I am facing same problem here.