Direct search in Alfred?

I have Spotlight Indexing enabled and am able to search in Drafts directly in Spotlight Search. I prefer to use Alfred however and am looking for a way to enable search directly in Alfred without needing to trigger a keyboard shortcut or workflow.

It seems like it should be possible because with DEVONthink, you can add the path ~/Library/Metadata/com.devon-technologies.think3 into Alfred’s file scope and Alfred will be able to locate any documents stored in that database directly, just like how Spotlight works (see: post). Is it possible to have this behavior for Drafts as well?

This thread about Alfred workflows has some workflows that enable search in Drafts. This works but I am looking for a way to search in Drafts without having to enter a keyboard shortcut, exactly like how Spotlight works.

1 Like

This is obviously an old thread, but the way that some other great apps have Alfred search (like this Bear workflow or this OmniFocus one) are through Python libraries that have been custom written. A pretty good DEVONThink workflow allows you to do similar things through JS instead of using Alfred’s regular file search. Something like this will have to be how it’s accomplished for Drafts.

Looking at the code, it looks like the Bear and Omnifocus workflows are both directly querying the App’s Sqlite database. It wouldn’t have to be written in Python, but without an API to query through, the approach should, in theory, give a nice quick response. This also assumes that Drafts is using a Sqlite database - which I think I’ve seen reference to it doing somewhere in the dim and distant past.

There’s a SQLite DB, yes, underneath Core Data. Not really recommended to access it from outside the app, but if you are doing it read-only you could prossibly get something workable out of it.

1 Like

For anyone coming across this thread, the Alfred workflow I created and discuss in this thread will allow you to search Drafts from within Alfred. It includes content and title based searches.

2 Likes