Bug 444896

Summary: FR: Search using wildcards does not work
Product: [Applications] dolphin Reporter: Adrian Fluturel <adrian.fluturel>
Component: searchAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: kfm-devel, s_chriscollins, tagwerk19
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Adrian Fluturel 2021-11-03 17:57:00 UTC
SUMMARY
When baloo is enabled, it ignores wildcards and searches anyway, but just in the areas that it indexes, as it should. But I should also be able to use wildcards to search for anything, which right now does not happen. When baloo is disabled, dolphin uses regular expressions, which do not accept wildcard expressions like "*.jpg"

STEPS TO REPRODUCE
1. Enable baloo
2. Search for something that only a wildcard would return, for example, if there is a file called "file_033.txt", searching with "*_033.t*" and successfully finding the file means wildcards are not ignored, while if it doesn't find it, it means they are ignored
3. Disable baloo and try again 

OBSERVED RESULT
The latter is the case here, baloo does not return the file requested with "*_033.t*" as a search term.
When baloo is disabled, nothing is found and in the console the message "QString::contains: invalid QRegularExpression object" is outputted.

EXPECTED RESULT
It should find the file using wildcards.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: kernel 5.14.15-zen1-1-zen
(available in About System)
KDE Plasma Version: Plasma not installed
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Dolphin version 21.11.70
Comment 1 tagwerk19 2021-11-04 11:21:04 UTC
(In reply to Adrian Fluturel from comment #0)
> The latter is the case here, baloo does not return the file requested with
> "*_033.t*" as a search term.
Sorry, this likely doesn't help you but you may need a different search tool for wildcard searches...

Baloo is tuned to provide fast results. It builds an index of things you _might_ search for and does lookups in that index as you type your search. That cannot really work for arbitrary wildcard searches.

It does however index parts of of filenames (and content) so you should get results if you search for "033" and also gives you matches for truncated searches such as "03"

You can see what terms baloo has indexed for a file with balooshow:

$ balooshow -x one-of-your-files
Comment 2 Adrian Fluturel 2021-11-04 20:54:48 UTC
(In reply to tagwerk19 from comment #1)
> (In reply to Adrian Fluturel from comment #0)
> > The latter is the case here, baloo does not return the file requested with
> > "*_033.t*" as a search term.
> Sorry, this likely doesn't help you but you may need a different search tool
> for wildcard searches...
> 
> Baloo is tuned to provide fast results. It builds an index of things you
> _might_ search for and does lookups in that index as you type your search.
> That cannot really work for arbitrary wildcard searches.

So what is a viable solution here? Add this in kio-filenamesearch?
Comment 3 tagwerk19 2021-11-04 21:40:13 UTC
(In reply to Adrian Fluturel from comment #2)
> So what is a viable solution here? ...
I don't know what the "More Search Tools" options can give here, it sounds as if you are looking for something like mlocate.

> ... Add this in kio-filenamesearch?
Don't know enough about the dolphin/filenamesearch/etc internals, I have to pass on that question.

Will flag as confirmed. Maybe someone else will come in with an "It's intentional"
Comment 4 Adrian Fluturel 2021-11-04 21:47:01 UTC
> Will flag as confirmed. Maybe someone else will come in with an "It's
> intentional"

Thank you. I talked for a bit on #kde-devel and people seem to think it's a wanted feature and it is wanted, and some thought baloo supported that already. I don't know much about dolphin or about kde in general, I'm just trying to get started and fix something, and this started like a pretty simple problem in theory but I am now getting in a rabbit hole of sorts that I don't know how to navigate
Comment 5 tagwerk19 2021-11-05 08:36:30 UTC
(In reply to Adrian Fluturel from comment #4)
> ... in a rabbit hole
That I can understand :-]

Yes, I think there's an assumption that you can use "*" (as a wildcard) and a surprise when it doesn't get you anything. It's a pretty gnarly problem though.

Dolphin makes it quite difficult to see whether you are using baloosearch versus filenamesearch. That makes sense to me (well...). The ideal would be that both give the same results except that baloo does the indexing work "up front" and gives you the results instantly and the filenamesearch does a slower "there and then" search. There are traps though that only start making sense when you know which is being used.

What dolphin does have is a "filter" (try a Ctrl-I) that gives you an additional dialog box at the bottom of the window. That *does* seem to understand wildcards so you can do a search, get a rough collection and then filter out what you want. It's well hidden though, would be nice if it "fitted in" with the dolphin search dialogs.