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.
> Fun fact: Dominic Giampalo (who wrote the BeOS file system) is on the APFS team. His book "Practical File System Design" is an excellent description of a traditional UNIX file system design. May be out of print now but I think used copies turn up on Amazon.
It looks like he has a PDF up on his website: