BeOS did it by writing their own filesystem. The filesystem author wrote a good book about the design and implementation, including overviews of other filesystems (eg NTFS). He has made the book available for free download at http://www.nobius.org/~dbg/practical-file-system-design.pdf
Ars Technica also has a nice 2010 article: http://arstechnica.com/information-technology/2010/06/the-be...
The way it implemented the queries well was because they were integrated into the filesystem. Windows/Mac/Linux do it in userspace. Doing it in the filesystem would be considered a layering violation by most.