Bug 308342

Summary: Search by age reports wrong results
Product: [Applications] kmail2 Reporter: Luis Silva <lacsilva>
Component: searchAssignee: kdepim bugs <kdepim-bugs>
Status: CONFIRMED ---    
Severity: normal CC: kdenis, kollix, luisfe, Martin, montel
Priority: NOR    
Version: 5.4.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Luis Silva 2012-10-13 20:28:39 UTC
The search by age in kmail does not and cannot work in it's current implementation.
In kdepim/mailcommon/searchpattern.cpp, the comparison is presently made with a QDate instead of a QDateTime. This makes the search not work at all.
Moreover, the age value is not subtracted from the present date but added. I have a patch correcting these issues but then the comparison is inverted, an issue I do not know how to correct. For example, searching for mail with an age "lower or equal" than "3 days" produces the following query (today is 2012-10-13):
select distinct ?r ?reqProp1 where { { ?r <http://akonadi-project.org/ontologies/aneo#akonadiItemId> ?reqProp1 . ?r <http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#sentDate> ?v1 . FILTER(?v1<="2012-10-10T23:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>) . ?r a <http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email> . FILTER EXISTS { ?r a [ <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#userVisible> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> ] . } . } . }

Reproducible: Always
Comment 1 Martin Koller 2013-02-04 14:20:12 UTC
I can confirm that the filter for "Age in Days" does not work with KDE-4.10 RC3
Comment 2 Laurent Montel 2013-08-31 09:12:30 UTC
it's right it doesn't work.
Comment 3 Laurent Montel 2013-10-07 07:28:03 UTC
I disabled date search in 4.12 because nepomuk doesn't have date support
it has datetime support but not date only support.
Wait that nepomuk will improve
Comment 4 luisfe 2014-09-15 17:17:11 UTC
In 4.14 one can still search by "age in days" but the result is plainly wrong.
Comment 5 Martin Steigerwald 2015-09-09 20:18:34 UTC
Hello Luis. Thank you for your report.

Laurent, is it possible to have search by age with with Baloo/Akonadi Search?

Thanks,
Martin
Comment 6 Denis Kurz 2017-01-13 14:38:28 UTC
What luisfe said in Comment 4, but for 5.4.1.

If the search backend (baloo, as it is now) does not support searching by age, the option should be removed from the search dialog.

I searched for messages younger than 3 days, and the search came up with every email I ever received, including very old ones and those from today or yesterday.