Implementation of /similarity REST endpoint

I think I'll end up refactoring checks for ordering like this as they'll show up in more places!