UI For Complex Boolean Searches
May 11, 2005

John Siracusa’s Tiger review includes a digression about boolean searches, which struck a chord with me.

He says “I think Apple has an insultingly low opinion of users’ ability to understand nested boolean logic. They may not know what it’s called, but the concept is intuitively understood”, and cites a number of Apple’s programs such as Mail and Spotlight which duck this issue by only allowing a single group of tests to be OR-ed or AND-ed, rather than allowing a query that can contain both ANDs and ORs, such as:

(genre is "Anime" or genre is "Game") and my rating is greater than 2 stars

This is something that’s always annoyed me too. Most applications don’t do it, and, I’ve usually found the interface to be pretty poor in the ones that do.

I’ve always thought that the best solution to this problem is to allow the “simple” expressions to be named and saved, and then to allow one simple expression to refer to the results of others. Siracusa actually mentions my approach as a “cumbersome” workaround, but I disagree, I think it’s actually a good pragmatic compromise. In my opinion, the alternative approach of allowing nested expressions and trying to implement an interface which allows them to be edited “in-line” in one big chunk generally ends in tears!

I can see that having to create named sub-clauses is not the fastest interface to use if you want to create a query on the fly, but then I find that any query requiring nested ANDs and ORs is likely to take more than one attempt to get right, and is also likely to be reused, so having an interface that forces you to name the sub-clauses and save them for later is no bad thing.

To illustrate what I mean, imagine a search filter interface which lets the user specify that a rule is true only if either “no test is true”, “any test is true”, or “all tests are true” (in other words, NOT, OR or AND). This is the interface that is provided with programs like Mail, iTunes and Spotlight.

Now imagine that one of the tests that you can specify is that another rule is true. This is the crucial step that is missing from most of Apple’s search interfaces (and lots of others), for no sensible reason that I can see.

The above example would be composed into two sub-clauses:

"Is Anime or Game" if any of the following is true: genre is "Anime" genre is "Game" "Is Good Anime Or Game" if all of the following is true: my rating is greater than 2 stars rule "Is Anime or Game" is true

The advantages of this approach are:

For me, just the simple addition of the ability to refer to the result of one rule or filter when defining another would vastly improve the utility of many programs. I’m even quite surprised that Apple hasn’t come up with a reusable interface for this sort of thing. It’s clearly something that would benefit from standardisation (like choosing files does, for example), and it ought to be relatively simple to come up with an API which dealt with displaying, editing, and storing rules whilst allowing application-specific code to be plugged in to implement that actual evaluation of results.

« Software Page Updated Decoding Crash Logs »
Got a comment on this post? Let me know at @samdeane@mastodon.org.uk.