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

Use regex to search the handbook for all words separately #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uramer
Copy link

@uramer uramer commented Jan 22, 2025

See https://discord.com/channels/302152934249070593/351624415039193098/1331565708265390132 and https://discord.com/channels/302152934249070593/351624415039193098/1331866085313740883 for Discord discussion

This makes the search results much more intuitive. For example, "plate iron armor" actually shows the relevant armor.

2025-01-22_23-51-55

One downside is that even very weak results (e. g. a single match in the page's body) are added to the list. It doesn't seem to cause significant performance issues, but might be a bit confusing. so I'm welcome to any suggestions of limiting that (e. g. at most 50 matches, but always include all results that have matches in the title).

I've tested international support only in Russian, as that was easily accessible to me, but I don't think there is any functional difference from the previous implementation there.

2025-01-22_23-45-52
2025-01-22_23-46-36

Comment on lines -152 to -161
public override float GetTextMatchWeight(string text)
{
/*string title = TextCacheTitle;
if (title.Equals(searchText, StringComparison.InvariantCultureIgnoreCase)) return 3;
if (title.StartsWith(searchText, StringComparison.InvariantCultureIgnoreCase)) return 2.5f;
if (title.CaseInsensitiveContains(searchText)) return 2;
if (TextCacheAll.CaseInsensitiveContains(searchText)) return 1;*/
return 0;
}

Copy link
Author

@uramer uramer Jan 22, 2025

Choose a reason for hiding this comment

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

I did not add the same override as I was not sure of its intended purpose, but obviously it's not difficult to bring back.

Choose a reason for hiding this comment

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

GetTextMatchWeight is intended to return weighted results based on things like titles being higher in the list than descriptions. Does your code adequately replace this weighting to make sure different things have different weights to them in the results?

Copy link
Author

Choose a reason for hiding this comment

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

I understand the purpose of GetTextMatchWeight, I was specifically referring to the commented out code.

Yes, it sorts all pages by title matches first, then breaks ties by page content matches, and then by title length to prefer more exact matches.

@uramer uramer force-pushed the regex-handbook-search branch from c10dd7b to 0a94d1a Compare January 23, 2025 06:20
@uramer uramer force-pushed the regex-handbook-search branch from 0a94d1a to 5eee39c Compare January 23, 2025 06:38
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.

2 participants