Support faceting in entities and relations listings. 

@scott2b I was wondering whether you might have a second to review this; it turned out to be more of a mess than I expected.