Skip to content

Made typos in docs searches return some results. #1930

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

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

sarahboyce
Copy link
Contributor

@sarahboyce sarahboyce commented Feb 5, 2025

When looking into #1347, there is a suggestion that we should show search results for "databasess" instead of a 404. However, this currently returns no results: https://docs.djangoproject.com/en/5.1/search/?q=databasess

Our search isn't very forgiving for spelling errors (not a "fuzzy" search).
As a suggestion, I think we can return some results that have a ranking instead of returning no results.

Fixes #1932

Copy link
Member

@pauloxnet pauloxnet left a comment

Choose a reason for hiding this comment

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

I tried to use Trigram for handling misspelling cases, but it was on the long list of things to improve, so thanks for working on that.

@sarahboyce sarahboyce force-pushed the search-updates branch 3 times, most recently from 46e930b to ef21dd7 Compare February 5, 2025 13:05
Copy link
Member

@pauloxnet pauloxnet left a comment

Choose a reason for hiding this comment

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

I had to test it locally to make sure I was proposing a solution that was as efficient as before. :)

I noticed that we were annotating the search rank without needing to show it, so I used "alias" and proposed the minimum number of code changes to have the suggested results in the list.

The SQL code generated with the suggested changes is slightly different but equally efficient and no longer produces the rank in output since it was not shown.

I restored the unmodified code with the previous formatting to make it easier to consult the Git history.

@sarahboyce sarahboyce force-pushed the search-updates branch 5 times, most recently from d078a09 to 1adfdb9 Compare February 6, 2025 07:26
@pauloxnet
Copy link
Member

Sorry @sarahboyce if I'm replying only now.

Thanks for continuing this PR, I tried to think better about the goal we want to achieve, and I opened the issue #1932

The goal I had in mind was to improve the current query, which I had created in the past, trying to maintain efficiency.

@sarahboyce sarahboyce changed the title Allowed low ranking search results to be returned in doc search. Made typos in docs searches return some results. Feb 7, 2025
Copy link
Member

@pauloxnet pauloxnet left a comment

Choose a reason for hiding this comment

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

Thanks again for so many updates in your PR.

@pauloxnet pauloxnet merged commit 9a43da9 into django:main Feb 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show results in documentation search on spelling errors
2 participants