Bug 480001

Summary: Add normal search as a fallback when searching in folder not indexed by baloo
Product: [Applications] dolphin Reporter: Tom <kde>
Component: searchAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: kdedev, kfm-devel, postix, tagwerk19
Priority: NOR    
Version First Reported In: 23.08.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=494155
https://bugs.kde.org/show_bug.cgi?id=420172
Latest Commit: Version Fixed In: 25.08
Sentry Crash Report:

Description Tom 2024-01-18 16:37:36 UTC
SUMMARY
If you search the internet for grief about Dolphin's search function, you will find a lot of hits for the same issue: https://www.google.com/search?hl=en&q=dolphin%20file%20search%20broken The indexed search with Baloo is not always reliable, leading to empty search results even in simple scenarios. I want to propose a change to remedy this at least in a few situations:
When search includes folders/files not indexed by baloo (For various reason: Not yet indexed, currently being indexed, excluded from indexing, etc), search these folders and files with the standard search. Merge the results from both searches and display these to the users. It might be prudent to display an info or warning to the user if searching will take longer because of this.

The use case in which I encountered this problem:
1. I downloaded a new folder with a huge amount of pictures
2. I searched for the simple and obvious name of a picture ("rome")
3. The file I was expecting ("rome arrival.jpg") didn't show up
4. When I checked the System Settings->Search window, Baloo was shown as "86% indexed, idle". 
5. I disabled Indexed Search and retried the search in Dolphin. The picture was immediately found with the exact same search query.


P.S.
My apologies if I got something wrong. I'm a first time KDE user and still learning :)
Comment 1 tagwerk19 2024-01-18 18:37:35 UTC
(In reply to Tom from comment #0)
> ... When search includes folders/files not indexed by baloo (For various reason:
> Not yet indexed, currently being indexed, excluded from indexing, etc),
> search these folders and files with the standard search ...
Searching with Dolphin is a labyrinth :-/

The "filenamesearch" and "baloosearch" backends don't pass queries back and forth between them (Here the filenamesearch is the code that does the "there and then" search, reading the data from the filesystem and giving you the "hits. "Baloosearch" queries a database that's built in the background.)

Ideally "filenamesearch" ought to be able to ask what baloo has indexed and query baloo for it (and therefore get results for these folders more quickly, and better results as baloo extracts and indexes the text of the files)

It's interesting to consider your perspective that a baloo query should do a "slow" search though the non-indexed folders.

There's a summary bug, listing the differences in behaviour between the two sorts of search here: Bug 463830

> 1. I downloaded a new folder with a huge amount of pictures
> 2. I searched for the simple and obvious name of a picture ("rome")
> 3. The file I was expecting ("rome arrival.jpg") didn't show up
You don't say what distro you are using, it's possible it makes a difference (particularly when dealing with loads of files)

You might find a "balooctl check" nudges Baloo to pick up the remaining files.

You are doing a search for a filename, that information ought to be indexed *remarkably quickly*. It is the searching through the content, opening each file, extracting the text that it would be useful to index, updating the database, that takes the time. You can use "balooctl monitor" to watch the stream of files being content indexed.

You might find that telling Baloo not to index content (just the filename and xattr metadata) would be enough for you.
Comment 2 Tom 2024-01-18 21:02:01 UTC
I'm using Arch. 
I repeated the same experiment with balooctl monitor running in the background. I re-enabled the indexed search in System Settings. I'm not sure how baloo reacts to a folder being deleted and recreated with the same name/content, so I chose a different directory name. I downloaded ~1500 pictures into this directory, which took about 10 Minutes. balooctl monitor was not showing anything but "indexer is idle" at this point. Then I searched for a picture name again. This time it showed up right away. I'm not sure which search was used for this now, though. So I used baloosearch on the command line. It didn't show any results for this new folder. So I assume it was not indexed. I ran balooctl check, but monitor did not show any news from the indexer. The system settings show the index at 84% as before and the indexer as idle.
Comment 3 tagwerk19 2024-01-18 22:53:23 UTC
(In reply to Tom from comment #2)
> ... I downloaded ~1500 pictures into this directory, which took about 10 Minutes ...
It sounds as if Baloo is not seeing the new files. 1500 pictures in 10 minutes should be absolutely no problem.

This is Arch with an ext4 filesystem, BTRFS or something more exotic?

It might be that the folder you are downloading into is not under your $HOME, possibly a separate partition? disk? remote drive?

You can troubleshoot by running "balooshow -x one-of-your-pictures.jpg", this will show the file metadata and various "embedded" tags. If this gives a result and baloosearch does not find it, then there's something wierd.
Comment 4 Tom 2024-01-18 23:28:14 UTC
This command returns "No index information found". balooctl monitor indicates the indexer is running. I noticed that my system settings freeze for a few seconds when I go to the search settings. Maybe that's related? It's still showing progress as 84% and the indexer as idle. (Monitor shows this as well now.)
My filesystem is ext4, and it's all on a rather fast Samsung nvme ssd. The folder is ~/Downloads/subfolder and /home/ is added to indexing in the System Settings. I have also specifically added ~/Downloads for this test.
Comment 5 tagwerk19 2024-01-19 10:32:01 UTC
That's most of the simple questions then :-)

Maybe see what

    systemctl status --user kde-baloo

says, check to see how big the baloo index is

    balooctl status

and then watch the processes with something like htop. You want to see whether baloo_file is being squeezed for CPU when it want to use too much memory (and constraints set in the unit file are limiting it)

See if you get anything in the journal, you can turn on debugging by creating a qtlogging.ini file:

    mkdir -p ~/.config/QtProject
    vi ~/.config/QtProject/qtlogging.ini

and adding

    [rules]
    kf.baloo=true

You can also ensure that any log or error messages sent to stderr get copied to the journal by editing the kde-baloo unit file:

    systemctl edit --user kde-baloo

and add line:

    [Service]
    StandardError=journal

and saving the override.
Comment 6 Felix Ernst 2025-04-07 21:09:21 UTC
Git commit 4102ccb80457eea44ea280f0ace2a419602bc34b by Felix Ernst.
Committed on 07/04/2025 at 21:09.
Pushed by felixernst into branch 'master'.

Rewrite search integration

This huge commit is a nearly complete rewrite of the Dolphin search
code. It implements most of the improved Dolphin search UI/UX as
designed and discussed in a collaborative effort by Kristen McWilliam,
Jin Liu, Andy Betts, Tagwerk, a few others and me.
See https://invent.kde.org/system/dolphin/-/issues/46.

# Notable changes

- A toggle to change the search tool is provided as most contributors
deemed that useful in
https://invent.kde.org/system/dolphin/-/merge_requests/642#note_985112.
- The default search is changed to filenamesearch for maximum
reliability.
- Removing all search parameters will take users back to the view state
prior to starting a search instead of keeping the search results open.
- The UI for choosing file types or modification dates has been made
more powerful with more granularity and more options.
- Most search parameters can be configured from a popup menu which
gives us extra space for extra clarity.
- Labels and help buttons as well as hyperlinks to settings makes sure
the user always knows why some search parameters are unavailable in
some contexts.
- Chips show important search parameters while the popup is closed.
They allow quickly removing filters.
- The titles of the search and the input field placeholder message
change to make clear whether file names or file contents are searched.
- When the user actively switches the search tool, whether content
should be searched, or whether to search everywhere, this is preserved
for the initial state of the search bar when the user opens it the next
time after restarting Dolphin.

# Architecture

- The new DolphinQuery class is independent of the UI and contains all
search parameters modifiable in Dolphin as easy setters and getters.
- DolphinQuery objects are also used to update the states of every
component in the search UI. There is now a clear separation of UI and
search configuration/DolphinQuery.
- DolphinQuery is responsible for exporting to and importing from
search URLs.
- The search UI always reflects the currently configured DolphinQuery
no matter if the user changed the UI to change the DolphinQuery or
loaded a DolphinQuery/older search URL which then is reflected in the
UI.
- I tried to simplify all classes and their interaction between each
other as much as possible.
- I added some tests
Related: bug 386754, bug 446387, bug 470136, bug 483578, bug 488047, bug 488845, bug 500103, bug 435119, bug 458761, bug 471556, bug 475439, bug 477969
FIXED-IN: 25.08

M  +19   -4    src/CMakeLists.txt
M  +5    -0    src/config-dolphin.h.cmake
M  +22   -17   src/dolphinmainwindow.cpp
M  +2    -6    src/dolphinrecenttabsmenu.cpp
M  +103  -130  src/dolphinviewcontainer.cpp
M  +41   -30   src/dolphinviewcontainer.h
M  +2    -2    src/global.h
A  +356  -0    src/search/bar.cpp     [License: GPL(v2.0+)]
A  +206  -0    src/search/bar.h     [License: GPL(v2.0+)]
A  +150  -0    src/search/barsecondrowflowlayout.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +48   -0    src/search/barsecondrowflowlayout.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +52   -0    src/search/chip.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +101  -0    src/search/chip.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +0    -0    src/search/configurationpopup.h     [License: Trivial file]
M  +5    -1    src/search/dolphin_searchsettings.kcfg
D  +0    -312  src/search/dolphinfacetswidget.cpp
D  +0    -84   src/search/dolphinfacetswidget.h
M  +339  -70   src/search/dolphinquery.cpp
M  +278  -37   src/search/dolphinquery.h
D  +0    -575  src/search/dolphinsearchbox.cpp
D  +0    -189  src/search/dolphinsearchbox.h
A  +378  -0    src/search/popup.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +99   -0    src/search/popup.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +61   -0    src/search/selectors/dateselector.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +42   -0    src/search/selectors/dateselector.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +81   -0    src/search/selectors/filetypeselector.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +36   -0    src/search/selectors/filetypeselector.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +51   -0    src/search/selectors/minimumratingselector.cpp     [License: GPL(v2.0+)]
A  +42   -0    src/search/selectors/minimumratingselector.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +189  -0    src/search/selectors/tagsselector.cpp     [License: GPL(v2.0+)]
A  +45   -0    src/search/selectors/tagsselector.h     [License: GPL(v2.0+)]
A  +56   -0    src/search/updatablestateinterface.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +67   -0    src/search/widgetmenu.cpp     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
A  +63   -0    src/search/widgetmenu.h     [License: LGPL(3+eV) LGPL(v3.0) LGPL(v2.1)]
M  +3    -3    src/tests/CMakeLists.txt
M  +1    -1    src/tests/dolphinmainwindowtest.cpp
M  +214  -64   src/tests/dolphinquerytest.cpp
A  +124  -0    src/tests/dolphinsearchbartest.cpp     [License: GPL(v2.0+)]
D  +0    -63   src/tests/dolphinsearchboxtest.cpp

https://invent.kde.org/system/dolphin/-/commit/4102ccb80457eea44ea280f0ace2a419602bc34b