Yes, you will lose all materia you melded into that piece of gear.
The upgrade is basically turning in the armor piece for a completely different piece of armor, so think of it more like purchasing brand new gear instead of upgrading (if that helps). The game treats the upgraded piece of armor as a completely separate item, which is also why the durability is reset to 100% (instead of carrying over the previous durability). Also any glamour you applied (I.E. glamoured esoteric gear) will be removed, because of the same reason. Upgradable armor is generally not dyeable, but this would apply to dyes as well.
It's best to wait until you get the upgraded pieces of armor before adding materia, so you are not wasting materia on gear you will have for several days.
Edit2: Replaced source with verification from a Community Rep: http://forum.square-enix.com/ffxiv/threads/284409-melding-lore-gear?s=7025e052adbd23e69bf38b780191fe56&p=3602391#post3602391