-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Ignore spaces and special chars in mod search #2709
Conversation
Could we speed this process up by adding fields to GUIMod with the filtered properties, so we aren't constantly applying multiple regexes to every line in GUIModList every time we refresh? This data isn't changing dynamically based on user input. |
If we add it to GUImod, we can use the feature only for the GUI. But generally I support the idea. Also we would have to save it for the name, identifier, author and description, maybe as an array? A wild idea: concatenate all 4 strings together in one field, and only have one search box for everything, looking if the search term is included in the concatenated string. |
one search box and 3 checkboxes, instead of the 3 search boxes? |
|
Good suggestions. When to calculate the 'Searchables'? |
I wouldn't attempt to optimize this further until after you've measured the performance using a static, compiled regex. Some portion of the slowdown you saw before is due to re-creating and compiling the regex over a thousand times, and it could be a large portion. Sorry, that probably wasn't clear: set the |
7908490
to
de9e996
Compare
Update: I do use a static, compiled, negated (non alphanumerics) regex now > performance is better. The calculations are done in the constructor of All UIs now search the abstract as well as the description. |
I want to put the calculations in a separate function in |
de9e996
to
54d003a
Compare
The calculations are now in a separate method: |
@HebaruSan we only print the identifier of the search results in the command line. Lines 40 to 44 in 16eeaf1
Wouldn't it make sense to list the mod names too? They are a bit user friendlier, I think. I would propose like this:
|
Yes, that would be nicer. The issue that came up last time in #2286 is that people might be running the CmdLine client in scripts that expect the old output, so any new format should probably be controlled by a new command line option. |
Okay. For consistency I would do it like #2286, via a --detail flag and with identifier, latest version and full name. |
Having the abstract could be nice if you're searching for a particular kind of mod rather than identifiers. E.g., you might want to find planet packs and then pick one based on its description. |
As long as you're going all-out for this, should there also be a way to include incompatible mods in the CmdLine search? It might be nice to see that I could install more planet packs if I marked 1.4 as compatible, for example. |
Support this. What about naming it |
Or |
54d003a
to
0422c25
Compare
I've updated the post with infos about all those shiny new options for the commandline search. |
Also add a --detail option to the command line search which displays mod name, version, KSP version and abstract on top. Add --all to allow the search of compatible and incompatible modules. Add --author <authorName> to allow search by a specific mod author.
0422c25
to
df698b1
Compare
Problem
If you want to search the mod list (in GUI, commandline or consoleUI), you have to know the name/identifier/author/description exactly, even spaces and special character.
There are a lot of mods with spaces and special characters in their name, sometimes even in the identifier indexed in the CKAN.
Examples:
(special char)
(special chars and spaces)
(no spaces)
It's nearly impossible to find a mod on the first try right now, if you don't know the exact name including all spaces, hyphens, brackets, dots...
Solution
On startup, more precisely during the deserialization of
CkanModule
s on load of registry, 'Searchables' are calculated for every mo and mod version, and saved during runtime inCkanModule
. The don't get serialized!Those 'Searchables' are
and represent special-characterless versions of their respective counterparts.
This means no spaces, no hyphens, no brackets and so on. Only alphanumerics remain.
They are calculated by removing each non-alphanumeric char from the source strings (regex
[^a-zA-Z0-9]
.If a mod search is done, the search term gets treated the same way.
This applies to all three interfaces, for all search types (author, description, name...).
Furthermore, I've improved the console search a bit. There's now also a
--detail
option (similar to the one inavailable
, see #2286) to list more than just the identifier, including the compatibility for KSP versions of the last mod version.The new
--all
option lists incompatible mods too. Without--detail
, they're mixed up in the compatibles, but with they are printed as two separate lists.Third, the
--author <authorName>
option allows to search for mods by a specific author. An emptysearch_term
is possible, to list all the mods of an author.So the search command can now range from
ckan search kerbal
tockan search --all --detail --author linuxguru RecycledPartsFTmNImprovedAtomicRockets
,something for everyone.
tl;dr:
ckan search --all --detail --author linuxguru RecycledPartsFTmNImprovedAtomicRock
finds RecycledPartsFTmNImprovedAtomicRockets by LGG in commandlineCloses #2708