The Crimson Binome
Hero
If the rules say that you can attack a swarm with a weapon, then it is a true fact of the world that swarms are susceptible to weapon attacks, and characters would know this based on having tried to smash spiders in the past, or from stories they have heard, or from any number of sources; if something is objectively true, then all evidence will be consistent with it. It is simply a case of their world being a different place from our world.If the characters have not fought the swarms previously in their lifes the only problem with your example would be players metagaming and complaining to take an advantage.
If the actual rule of how the world works is different than that in the book, then the character would instead be aware of that. If it's a true fact of the world that you can't smash spiders with a morningstar, and attempting to fight a whole swarm in such fashion would be as ridiculous as we'd expect in real life, then all evidence would instead support that conclusion. The characters would be aware of this, and players should make their decisions based on that fact.
The issue is when a DM institutes a house rule to make things more realistic (you can't stab a swarm), but the player is still operating on character-logic (which says you can stab a swarm). Unless you actually tell the players about your house rules, it would be meta-gaming on their part if they assumed anything worked as it does in real life rather than how it does in the book. Barring those rare cases of true malicious intent, most accusations of meta-gaming are actually just failure by the DM to respect that characters are real people who have a basic understanding of how their world actually works, just because their world works differently from our world.