-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.x] Expand Full-Text Search capabilities #40583
Conversation
f12afb1
to
189d76c
Compare
If you don't usw the I will look at the PR and it's effect on PostgreSQL later. But I don't share the actual implementation idea. It's making a simple "order by ranking" logic very complicated as I have to add a select part (which I don't need) and then sort by that column. I, personally, would prefer an |
@tpetry my knowledge about full text search doesn't extends that far. I suggest you both work on this PR as you see fit and mark it as ready when you think it's valid for review. |
Great point @tpetry .. and not a consideration I'd realised. How would you see the orderByFullText() operating - would it add the where condition AND the order by clause? |
@tpetry I guess my main goal in all this is a way of getting the results ordered by relevance. Having the score value available from the select clause is very much secondary (although I could see some uses for it, e.g. displaying a %-age relevance score on a results page). I'm sure I read somewhere that if there's no other ordering specified on the query and a fulltext MATCH is used, MySQL will order the result by descending relevance by default, but I can't seem to replicate that in manual query tests on my local db. I'm not sure if it's actually true, or just a rumour from something I Googled. |
@tpetry Looking at the MySQL docs:
So that confirms that needing the relevance score to actually be available as a result table column is really the only reason for a select-based MATCH..AGAINST. I'm interested as to what you'd think an |
We've fixed the build on 8.x so please rebase, thanks! |
189d76c
to
7c4d0e0
Compare
Just the
The score is an implementation detail, it's not really a percentage value. A perfect document can be a
As stated in the documentation, automatic ordering will not happen in some cases for joins. But reducing your question to it's basic statement would make this PR obsolete as MySQL is doing sorting completely automatic? Additionally, manual sorting together with rank-based sorting may be used. |
@tpetry Thanks, and you're right, now I've realised the ordering happens automatically in MySQL, and the score value isn't really useful, this whole PR is probably redundant. I'll close! Sorry for the time-waste @driesvints :( |
@jonnott don't worry about it 👍 |
It's useful for PostgreSQL as it does not do any automatic sorting, I will work on a PR the next week. |
Following on from @driesvints' excellent work in #40129, this adds selectFullText() and addSelectFullText() methods.
Whilst whereFullText() is useful in itself, an arguably more practical use-case for fulltext search queries involves being able to select the relevance score in the query, filter to only results with > 0 relevance score using a having clause, and ordering the results by relevance).
This is a scenario used in the fulltext search lesson of @reinink's Eloquent Performance Patterns video course, except there the MATCH()..AGAINST() is used in with select and where clauses, which isn't actually necessary .. see 'Ordering By Result Relevance' section here https://www.cloudsavvyit.com/10172/how-to-use-full-text-searches-in-mysql/
Example (assuming a fulltext index exists on 'bio,resume' (both
string
) fields):TODO: