Skip to content
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

FEATURE: include tag and category context in search #217

Merged
merged 3 commits into from Sep 12, 2023
Merged

Conversation

SamSaffron
Copy link
Member

Previous to this we just included title/body.. tags and category
structure can be very critical for decision making.

Previous to this we just included title/body.. tags and category
structure can be very critical for decision making.
(not its responsibility to test)
vinothkannans

This comment was marked as resolved.

Copy link
Member

@vinothkannans vinothkannans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👌

@SamSaffron
Copy link
Member Author

thanks @vinothkannans was thinking about this and there are some N+1s here ... not sure how easy it is to fix though ... its all in a background job and most of the time you are waiting for LLM, but maybe I should fix.


if SiteSetting.tagging_enabled
hidden_tags ||= DiscourseTagging.hidden_tag_names
# using map over pluck to avoid n+1 (assuming caller preloading)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of assuming can we check whether the association is loaded or not? like post.topic.association(:tags).loaded?. And we can raise an error if it's not loaded.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is the responsibility of Search or SemanticSearch ... but maybe we can raise a warning in case this happens.


if posts.blank?
{ args: search_args, rows: [], instruction: "nothing was found, expand your search" }
else
format_results(posts, args: search_args) do |post|
{
category_names = [
post.topic.category&.parent_category&.name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how the search command is executed in the background. Will it cause n+1 in category and parent_category attributes too?

@SamSaffron SamSaffron merged commit d75e3ca into main Sep 12, 2023
4 checks passed
@SamSaffron SamSaffron deleted the better_search branch September 12, 2023 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants