Extend the search to include comments #160
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main search functionality was already implemented. What I did was extending the existing SearchVector with some attributes from the
comments
andprofile
model:comments__body
comments__user__first_name
comments__user__last_name
comments__user__email
.All new vectors got the weight
A
(because it was not specified which weight they should have). I also added adistinct()
to the search query to avoid duplicates in the query result.With this approach two new joins where introduced in the query. I did some performance measurements with an empty and with an lightly filled database and I didn't see any performance issues so far. I guess it depends how much data are in the specific tables.
This task was straight forward and I didn't need much time for it. I also added one test to the model tests.