Skip to content

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Oct 13, 2025

I know adding 2 new phases for exact matches feels like a workaround, but without a more thorough review on the entire searching algorithm this is the best solution I have.

I also added basic tests for search.js using mini_racer gem (dev dependency) to simulate JS evaluation. I chose this approach because it should be simpler than maintaining a whole set of JS dependencies and setups.

Fixes #1194

@matzbot
Copy link
Collaborator

matzbot commented Oct 13, 2025

🚀 Preview deployment available at: https://dcca3028.rdoc-6cd.pages.dev (commit: b3dcacc)

When searching for a class name like "String", the search should
return exact matches first before returning classes that contain
the search term in their name (like "Prism::StringNode").

This adds a new pass 0 to the search algorithm that only matches
when the searchIndex exactly equals the query. The previous passes
are shifted accordingly:
- Pass 0: exact match (new)
- Pass 1: searchIndex starts with query (was pass 0)
- Pass 2: longSearchIndex starts with query (was pass 1)
- Pass 3: searchIndex contains query (was pass 2)
- Pass 4: regexp match (was pass 3)

Fixes #1194
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.

curious search result order on docs.ruby-lang.org

3 participants