Bug 332143

Summary: Search by content only searches in files whose mime type begins with "text/"
Product: [Applications] dolphin Reporter: Mariusz <fisiu82>
Component: searchAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: cyberbeat, fisiu82, hrvoje.senjan
Priority: NOR Keywords: investigated
Version: 4.12.3   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 4.12.4
Sentry Crash Report:

Description Mariusz 2014-03-14 15:37:37 UTC
Searching by content returns incomplete results comparing to grep or krusader.

I have some directory (~/.bash_it → git@github.com:Fisiu/bash-it.git). When I run `grep -rl "scm_prompt_info" . | wc -l` or krusader serach, in both cases I got 20 files which contain "scm_prompt_info" phrase. When I do the same search in Dolphin (tested on 4.11.5 and 4.12.3), then search result contains only 7 files. No matter if nepomuk indexing is enabled/disabled.

Reproducible: Always
Comment 1 Frank Reininghaus 2014-03-14 15:56:25 UTC
Thanks for the bug report. I can confirm this.

The problem is that we only search the text inside files which have a mime type that begins with "text/".

All your files that contain "#!/usr/bin/env bash" at the beginning have the mime type "shell script" and are not considered as text files.

I'm not sure what to do about this. I would prefer not to maintain a Dolphin-internal list of mime types that usually contain plain text... (and such a list would not help at all, because it would only work if Nepomuk is disabled, and the Dolphin-internal 'filenamesearch' is used).
Comment 2 Mariusz 2014-03-14 16:06:08 UTC
And how krusader does handle searching by content? Maybe theirs solution applies.
Comment 3 Frank Reininghaus 2014-03-14 16:11:25 UTC
Ah, I just looked through the API docs - it seems that we can use mime type inheritance, like

KFileItem item(....);
if (item.determineMimeType()->is("text/plain")) {
    // Check if the file contains the text...
}

Probably Krusader uses the same solution (or they search in all files).
Comment 4 Frank Reininghaus 2014-03-15 09:50:50 UTC
I have a patch that fixes the problem for me:

https://git.reviewboard.kde.org/r/116805/

@Hrvoje: I see that you read this report. Should a separate report be filed for Nepomuk/Baloo?
Comment 5 Hrvoje Senjan 2014-03-15 15:47:53 UTC
(In reply to comment #4)
> @Hrvoje: I see that you read this report. Should a separate report be filed
> for Nepomuk/Baloo?

You mean is the same bug valid with nepomuk/baloo on ? 
At the moment i have downgraded from 4.13 to 4.12 due to some issues, and i am normally not using nepomuk. i can try to activate it and test with another user if needed ;-)
Comment 6 Frank Reininghaus 2014-03-16 17:06:18 UTC
Git commit c52ba9446b05e6bc7f890daac406659a9c37c562 by Frank Reininghaus.
Committed on 16/03/2014 at 17:02.
Pushed by freininghaus into branch 'KDE/4.12'.

Use MIME type inheritance to find out if a file contains text

Before this commit, filenamesearch checked if a file's MIME type begins
with "text/" to determine if its content can be searched. This prevented
that text inside shell scripts is found.
REVIEW: 116805
FIXED-IN: 4.12.4

M  +4    -1    dolphin/src/search/filenamesearchprotocol.cpp

http://commits.kde.org/kde-baseapps/c52ba9446b05e6bc7f890daac406659a9c37c562
Comment 7 Frank Reininghaus 2014-03-16 17:08:02 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > @Hrvoje: I see that you read this report. Should a separate report be filed
> > for Nepomuk/Baloo?
> 
> You mean is the same bug valid with nepomuk/baloo on ? 

According to comment 0, yes, but I haven't tested it myself.
Comment 8 Frank Reininghaus 2014-05-02 15:26:35 UTC
*** Bug 314607 has been marked as a duplicate of this bug. ***