Skip to content

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Dec 16, 2025

Rebuild Aliki's search mechanism with a custom search index and improved ranking algorithm.

Key changes:

  • Aliki now generates its own search index (js/search_data.js) instead of using the shared JsonIndex generator (can be removed along with Darkfish in the future)
  • New search ranking algorithm with better prioritization:
    • Lowercase queries prioritize methods; uppercase queries prioritize classes/modules/constants
    • Exact matches rank higher; shorter names preferred
    • Class methods rank above instance methods (I don't have strong opinion on this one)
  • Search results now display type badges (class, module, const, method)
  • Constants are now included in search results

Closes #1497

Screenshot 2025-12-16 at 17 57 50

@matzbot
Copy link
Collaborator

matzbot commented Dec 16, 2025

🚀 Preview deployment available at: https://5ad0d5cc.rdoc-6cd.pages.dev (commit: f4a8cdf)

@st0012 st0012 marked this pull request as ready for review December 16, 2025 18:04
@st0012 st0012 added the bug label Dec 16, 2025

if (isNamespaceQuery) {
// For namespace queries like "Foo::B", match against full_name
if (!fullNameLower.startsWith(queryLower)) {
Copy link
Member

Choose a reason for hiding this comment

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

Query that contains # should also match against full_name.
For example, Array#filter should match to something but currently it doesn't.
(Search with filter in ruby/ruby's doc and press down arrow will fill Array#filter to the search form.)

matchScore = 100;
} else {
// For regular queries, match against unqualified name (prefix match)
if (!nameLower.startsWith(queryLower)) {
Copy link
Member

Choose a reason for hiding this comment

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

I often search methods that includes query in IRB, like:
Kernel.methods.grep /_defined\?/

Can we include substring match? and prioritize lower than prefix match.

@tompng
Copy link
Member

tompng commented Dec 17, 2025

I don't think the current search is bad, except for the search result order and constant not searched.
It has advanced search: query = add_alias match to add_module_alias.

How about first match against full_name with regexps generated by the old searcher, and then reorder the result with score?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Classes named like common methods are very difficult to search for

4 participants