rails / sdoc

Standalone sdoc generator
http://api.rubyonrails.org/
Other
820 stars 131 forks source link

Adjust module vs method ranking in search results #343

Closed jonathanhefner closed 11 months ago

jonathanhefner commented 11 months ago

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.

p8 commented 11 months ago

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