We introduce a new method for the identification of galaxy systems in redshift surveys based on the halo model. This method is a modified version of the K-means identification algorithm developed by Yang et al. We have calibrated and tested our algorithms using mock catalogues generated using the Millennium Simulations and applied them to the NYU-DR7 galaxy catalogue (based on the SDSS data sets). Using this local sample of groups and clusters of galaxies, we have measured the effect of gravitational redshift produced by their host dark matter haloes. Our results show radial velocity decrements consistent with general relativity predictions and previous measurements by Wojtak et al. in clusters of galaxies.