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

Adjust module vs method ranking in search results #343

Conversation

jonathanhefner
Copy link
Member

Prior to this commit, modules would rank above methods in search results. This ensured, for example, that ActionController::Rendering would rank above ActionController::Rendering#render when searching for "ActionController::Rendering". However, ActionController::Rendering would also rank above ActionController::Rendering#render when searching for just "render". Though the method does rank first when searching for "#render" or ".render", such queries may not be intuitive.

Based on the idea that users will be searching for either a module or a method, this commit removes the higher-ranked module-specific ngrams from method entries in the search index. For example, the method entry for ActionController::Rendering#render will no longer include the ":Ac", " Ac", ":Re", and " Re" ngrams (though it will still include the "Act", "Ren", etc ngrams).

Furthermore, this commit changes the tie-breaker bonuses to be reduced in proportion to just the method name for methods or the module name for modules, whereas before it was reduced in proportion to the fully qualified name for both methods and modules.

The end result is that ActionController::Rendering still ranks above ActionController::Rendering#render when searching for "ActionController::Rendering", but ActionController::Rendering#render now ranks above ActionController::Rendering when searching for just "render".

Fixes #330.

Prior to this commit, modules would rank above methods in search
results.  This ensured, for example, that `ActionController::Rendering`
would rank above `ActionController::Rendering#render` when searching for
"ActionController::Rendering".  However, `ActionController::Rendering`
would also rank above `ActionController::Rendering#render` when
searching for just "render".  Though the method _does_ rank first when
searching for "#render" or ".render", such queries may not be intuitive.

Based on the idea that users will be searching for _either_ a module
_or_ a method, this commit removes the higher-ranked module-specific
ngrams from method entries in the search index.  For example, the method
entry for `ActionController::Rendering#render` will no longer include
the ":Ac", " Ac", ":Re", and " Re" ngrams (though it will still include
the "Act", "Ren", etc ngrams).

Furthermore, this commit changes the tie-breaker bonuses to be reduced
in proportion to just the method name for methods or the module name for
modules, whereas before it was reduced in proportion to the fully
qualified name for both methods and modules.

The end result is that `ActionController::Rendering` still ranks above
`ActionController::Rendering#render` when searching for
"ActionController::Rendering", but `ActionController::Rendering#render`
now ranks above `ActionController::Rendering` when searching for just
"render".

Fixes rails#330.
@p8
Copy link
Member

p8 commented Oct 26, 2023

Thanks! This seems to work a lot better for me. 🚀

@jonathanhefner jonathanhefner merged commit 2c29dfb into rails:main Oct 26, 2023
8 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.

Methods not showing up in search results
2 participants