Following up my question about grappling conditions on swarms, a situation came up in my group when the Druid attempted to use the spell Thorn Whip to pull a swarm of piranhas on shore to defeat them, which brought up the question in the title. This has not been addressed in the Monster Manual Errata to my knowledge.
Rulings versus Rules in 5e D&D
This looks like a case of rulings versus rules, since you note that there isn't a codification beyond the errata cited in this answer, i.e. swarms cannot be Grappled. (Immunity to Grappled Condition1).
I can see a given DM ruling either way. (As an aside, if you wanted to jump into the river to grapple with a swarm of piranhas, I'd give you a new nickname on the spot: Chum or Chumley.)
PHB p. 282
If the attack hits, the creature takes 1d6 piercing damage, and if the creature is large or smaller, you pull the creature up to 10 feet closer to you.
The Case for No
Because the swarms cannot be Grappled, per the errata, then getting control of the Swarm cannot be done via that Thorn Whip any more than it can with a regular whip, or other means of Grappling a creature.
Justification: the difference between wrapping a whip around a creature to get control of it, and the term "Grapple," is negligible since the general effect is the same. (The whip would on a successful attack grab one piranha and deliver it to you, damaged).
The Case for Yes
This whip is magic. Since the spell description does not explicitly state that it Grapples the creatures, the magical force made by the whip does what it needs to do to wrap itself around the swarm and pull it to you, dealing suitable damage along the way.
Justification: Well, it's magic, and the words don't say anything about Grapple in the spell.
Discuss with your DM and accept the ruling.
If you are the DM, make the ruling that seems most sensible to you.
I like the 'rule of cool' regarding a novel way to go fishing, if you and the party are dying for some blackened piranha for dinner.
On the nature of Swarms
They form as a result of some sinister or unwholesome influence ... even Druids can't charm these swarms, and their aggressiveness is borderline unnatural. (MM p. 337)
This raises the question of whether or not a Swarm is a single creature, or something quite different from that. In aggregate, the nature of "swarming" makes a bunch of single creatures act collectively and thus pose a greater danger to a party than a few rats, piranhas, or bats. (Consider that a squad of soldiers or goblins is far more dangerous than a single soldier). A Swarm does more damage in "swarm" form, so for the purposes of melee and movement (in formation, however chaotic) a Swarm is treated as a 'creature' even though the Swarm is made up of a bunch of smaller creatures.
- This may support the "no" answer if getting that granular makes the ruling make more sense.
- It supports the "yes" answer, per @nitsua60's comment, since the "unwholesome influence" that creates them also constrains them to a smaller-than-they'd-naturally-choose volume, so perhaps grabbing and pulling one would be sufficient to bring them all along as they maintain unit cohesion (of a "borderline unnatural" sort).
1 Swarm of X (p. 337–39). Condition immunities: every swarm is immune to being grappled. Credit to @nitsua60 for comment to add Condition as a game term.
In the specific case of Thorn Whip, no. Per the spell:
You create a long, vine-like whip covered in thorns that lashes out at your command toward a creature in range.
It creates a vine like contraption through transmutation that grabs at the target creature. For a creature that is Large, or smaller, it is pulled 10 feet closer to you.
When applied to a swarm thematically, such as rats or piranha, the Thorn Whip may be able to grab a single member of the swarm, it is doubtful that it could ensnare the entire swarm.
In a general sense, it depends on the mechanical nature of the effect and how it would interact with the swarm. A broad all encompassing effect will be more effective than a narrow, targeted effect. As a comparative example, consider Thunderwave:
A wave of thunderous force sweeps out from you. Each creature in a 15-foot cube originating from you must make a Constitution saving throw. On a failed save, a creature takes 2d8 thunder damage and is pushed 10 feet away from you.
In that case, the swarm would be affected.