The Gaia-ESO Survey: the selection function of the Milky Way field stars