What does the word hej in the song hej sokoły or in hej bistra woda mean?
as for hej, it's more a way of calling to someone to get their attention more than a greeting.
In modern Polish 'halo' (hallo?) works the same way, getting the attention of someone whose name you don't know.
hej is actually used more as a goodbye but usually not on its own. Often Polish people will string together three or more expressions when saying goodbye "na razie, cześć, pa, hej"