You totally can know up-front. My colleague's Linkedin bio clearly states "Not interested in contract work.", once in a blue moon he'll get a recruiter that actually read his profile!
Likewise, while I've gotten some pitches that aren't in my domain, and 2 that weren't even software engineering gigs, I'd say 90% of emails seem to at least be loosely in the ballpark, and of those half of them seem like "okay, it at least got the right kinds of positions). Most of the rest tends to be web development for some reason, though (again, I don't have any specific request on my LinkedIn).