You realize there's no better place for a spear than in a tight indoor area right? They have to get into range to hit you and that means coming through the pointy bit. Swords are much less easy to use in any of the ways they are better than a spear in a confined space. So ultimately in an indoor area you want a pointy stick you can repeatedly thrust forward while being out of range of counter attacks. Unless your opponent can grab hold of it they have no way to ever hurt you in melee. Even if they get past the tip you can always pull it back and have the pointy bit in front of them again.
Spears are handy in doors until you meet a corner, a barrier (e.g. a door) leading into a larger space, enter tight quarters, or if they get past the pointy end in some other way. There's a reason why the classic spear fell out of favor compared to multi purpose weapons (e.g. halberd, poleaxe). They are easy to manufacture, maintain, store and use, but at the end of the day their sharp point is all they have. Frankly, they've reached the same bullshit mythical proportions as the Katana at this point.
Greatswords in particular were used to get past spears. A big sword is a really big pointy stick allowing you to engage that pointy end of the spear from a distance, and once you've past that you have the benefit that a sword also has a very shard edge!