-
-
Notifications
You must be signed in to change notification settings - Fork 834
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
Improve search performance #1339
Conversation
src/Discussion/Discussion.php
Outdated
*/ | ||
public function mostRelevantPost() | ||
{ | ||
return $this->belongsTo('Flarum\Post\Post', 'most_relevant_post_id'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this will only be used when searching, right? Because most_relevant_post_id
will just be the name of a dynamically calculated column? If so, that should be made clear in the docblock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point.
Do you already want a more detailed review here? If not, just let me know when this is no longer WIP. |
@franzliedke I will request one when I push some further changes soon, thanks :) |
This change relies on the `visibility-scoping` branch to be merged.
Doing a JOIN between an InnoDB table (discussions) and a MyISAM table (posts) is very very (very) bad for performance. FULLTEXT indexes are fully supported in InnoDB now, and it is a superior engine in every other way, so there is no longer any reason to be using MyISAM.
I was thinking related to my pr #1344, again we're adding mysql only raw statements in a migration. We should try to investigate whether we can encapsulate these statements in a conditional whether we're running the correct driver. Otherwise we'll never be able to support more db drivers 😞 |
For the moment, the intention is for the gambit class itself is acting as the encapsulation, so it should probably be renamed to Different search drivers (eg. ElasticSearch, Algolia) can be implemented by replacing this gambit via For 0.2 (or later) we have plans to overhaul the search API: https://github.com/flarum/core/issues/1355 |
@tobscure what I was referencing was the migration and the actual One way would be to check the |
@luceos Ah I see. True. But let's defer until we actually implement support for other db drivers before changing the migrations. Even if we wrap in a conditional now, other db drivers still aren't going to work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave it a spin and I'm very much impressed by the looks! Well done, picking part of the post really creates a rich search experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. 👍
Is this still WIP? |
Nope, it's done :D |
@tobscure I am wondering... should we move the mostRelevantPost stuff into its own pseudo-model, or at least API resource. That way, we don't stuff the discussion model with things that are only relevant for search results. Could be something like |
Good thought. Could be |
Yeah, sounds good. Will you try it out? |
Actually, after more thinking, I don't think it makes sense to do this from a JSON-API perspective. |
True. We could do a separate endpoint just for searching, but at that point, it probably gets too crazy in another way. 😉 Thanks for considering! |
@tobscure Mysql 5.5 can't use fulltext in InnoDB. It only support above 5.6. Will Flarum require mysql 5.6 at least. |
Have made a note in the relevant issue flarum/docs#14 |
Todo:
discussions.title
(we can leave the table as InnoDB - we should probably convertposts
to InnoDB at some point too)Overhauled search extensibility API will come later (0.2?) but for now some level of search extension can still be achieved by replacing the default fulltext gambit with a custom one.