Spotlight query fails when kMDItemFSLabel is used along with other criteria

Originator:pierre.bernard
Number:rdar://8613595 Date Originated:30-Oct-2010 08:04 PM
Status:Open Resolved:
Product:Mac OS X Product Version:10.6.4
Classification:Serious Bug Reproducible:Always
 
The transcript below shows the problem as exhibited by mdfind. The MDQuery API exhibits the same issue.

I have a folder with 4 image files: teaser0.png teaser1.png teaser2.png teaser3.png
The file teaser0.png has Finder label 2.
The file teaser1.png has Finder label 5.

Using mdfind to find all files named *teaser* produces the expected result.
Using mdfind to find all files with Finder label equal 2 produces the expected result.
Using mdfind to find all files with Finder label NOT equal 2 produces the expected result.
Using mdfind to find all files named *teaser* AND Finder label equal 2 produces produces the expected result.

However:
Using mdfind to find all files named *teaser* AND Finder label NOT equal 2 produces an empty result.


$ cd '/Users/pierre/Desktop/picts/'
$ ls
teaser0.png teaser1.png teaser2.png teaser3.png
$ mdls teaser*.png | grep kMDItemFSLabel
kMDItemFSLabel                 = 2
kMDItemFSLabel                 = 5
kMDItemFSLabel                 = 0
kMDItemFSLabel                 = 0
$ mdfind -onlyin . "((kMDItemDisplayName == '*teaser*'cd) ))"
/Users/pierre/Desktop/picts/teaser3.png
/Users/pierre/Desktop/picts/teaser0.png
/Users/pierre/Desktop/picts/teaser1.png
/Users/pierre/Desktop/picts/teaser2.png
$ mdfind -onlyin . "(kMDItemFSLabel = '2')"
/Users/pierre/Desktop/picts/teaser0.png
$ mdfind -onlyin . "(kMDItemFSLabel != '2')"
/Users/pierre/Desktop/picts
/Users/pierre/Desktop/picts/teaser2.png
/Users/pierre/Desktop/picts/teaser1.png
/Users/pierre/Desktop/picts/teaser3.png
$ mdfind -onlyin . "((kMDItemDisplayName == '*teaser*'cd) && ( (kMDItemFSLabel != '2') ))"
$ mdfind -onlyin . "((kMDItemDisplayName == '*teaser*'cd) && ( (kMDItemFSLabel == '2') ))"
/Users/pierre/Desktop/picts/teaser0.png
$ mdfind -onlyin . "((kMDItemDisplayName == '*teaser*'cd) && ( (kMDItemFSLabel > '2') ))"
/Users/pierre/Desktop/picts/teaser1.png
$

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!