Melchizedek is a somewhat enigmatic figure in the Bible. He only appears in Genesis, Psalms and Hebrews.
He was a worshipper of Jehovah, but was not from Abraham’s family and, therefore, by definition, was not a Jew. Apparently, he was the king of Salem, which is now called Jerusalem. In Genesis 14:18-20 we see that, for whatever reason, Abraham gave an offering to Melchizedek, as the King of Salem was a priest of Jehovah.
We do not have a lot to go on there, but the basics are that Melchizedek was a priest of Jehovah, but clearly he was not descended from Levi, so he was not a Levitical priest.
In Psalm 110:4-7 we have an equally enigmatic messianic prophecy about Melchizedek. It appears to indicate that the Messiah will be a priest of God–not from the lineage of Levi, but rather from Melchizedek. God swears that this will be so, and God does not swear often! (Hebrews 6:13-17)
It is in Hebrews 7 that all this comes together. Melchizedek was a real person, but God uses him as a prefigure of the Messiah. Like Melchizedek, Jesus is the King of Peace (Salem means peace). Like Melchizedek, Jesus is a priest, not by descent from Aaron/Levi but because of his own righteousness. We know nothing, either of Melchizedek’s parents, nor his offspring. The Hebrew writer make an odd application of this fact when he says that Jesus is like Melchizedek in that he says of Jesus, “without father or mother, without genealogy, without beginning of days or end of life, like the Son of God, he remains a priest forever.” I am not sure that Melchizek was like Enoch in that he did not die. To be honest, I am not exactly sure what the Hebrew writer is referring to, but in any case, there are many analogies between Jesus as priest of the New Covenant and Melchizedek as a priest of God, by righteousness rather than by birthright.
The Hebrew writer uses the fact that Abraham offered a sacrifice through Melchizedek to symbolize that the lesser, Mosaic covenant would be replaced by the greater covenant of Jesus. He tells us that Jesus is a priest like Melchizedek, not like Aaron. The overall point of the Hebrew writer is that with Melchizedek as a prefigure of Christ we learn that a greater covenant was prophesied from the time of Abraham, and that Jesus is the fulfillment of that promise. His is the new and greater priesthood that brings real righteousness to those who are saved by his sacrifice.
As for Melchizedek and Shem, I do not know where you got that idea, but Melchizedek lives hundreds, if not thousands of years after Shem, so that idea is ruled out.
I am not sure whose genealogy you are asking about–Shem or Melchizedek. I will assume your are asking about Melchizedek. One of the points of the writer of Hebrews in chapter seven is that we know nothing, either of his ancestors or of those who came after him, so the answer is that we know nothing of his genealogy.