Spotlight has been in Mac OS X for quite awhile now, but in general, I haven’t found it very useful. However, when this tip came across at Mac OSX Hints on how to use operators for ranges in Spotlight metadata I got some ideas about doing geo-searches on my desktop machines.
To summarize, Spotlight is a system-wide metadata storage engine. Mac OS X provides a nominal vocabulary of metadata you can store, but you can also extend this to add your own metadata. Various applications like Yojimbo add metadata keys to store tags and other info with files. What’s especially great is that by applications using Spotlight, it means you can tie into this underlying metadata without having to use the application itself.
Using simple command-line parameters, you can do search for words, or specific metadata such as file type:
mdfind -s "Hawaii"
mdfind -interpret "keyword kind:image"
Great, but what about the range queries and Geo search? One of the default metadata items stored are
kMDItemLongitude. In fact, you can use
mdimport -A to get a list and description of all available metadata items.
You can then do geographic queries like:
latitude:<20 longitude:>20 and get all files you’ve created (such as photos or documents) while in Hawaii. You can also do better bounding box searches. To play with this I wrote a small RubyCocoa app to do geographic queries and display the location on a map.
GeoSpotlight allows you to search without a box and add other Spotlight predicates to search by, say, keyword, title, city, time, etc. Check out the Query Expression Syntax for details on how to do this.
This was a quick mock-up and I’ll probably extend it to do bounding box specifying using the map interface and also locating documents via drag and drop.
- GPS-enabled powerbooks
- OpenSearch Geo and Time extensions
- Amazon tag-soup and user wishlists
- GeoFeed ‘pagination’
- EXIF NewsCodes