The microbiomes of rhizocompartments (nodule endophytes, root endophytes, rhizosphere and root zone) in soya bean and alfalfa were analysed using high-throughput sequencing to investigate the interactions among legume species, microorganisms and soil types. A clear hierarchical filtration of microbiota by plants was observed in the four rhizocompartments - the nodule endosphere, root endosphere, rhizosphere and root zone - as demonstrated by significant variations in the composition of the microbial community in the different compartments. The rhizosphere and root zone microbial communities were largely influenced by soil type, and the nodule and root endophytes were primarily determined by plant species. Diverse microbes inhabited the root nodule endosphere, and the corresponding dominant symbiotic rhizobia belonged to Ensifer for alfalfa and Ensifer-Bradyrhizobium for soya bean. The nonsymbiotic nodule endophytes were mainly Proteobacteria, Actinobacteria, Firmicutes and Bacteroidetes. The variation in root microbial communities was also affected by the plant growth stage. In summary, this study demonstrated that the enrichment process of nodule endophytes follows a hierarchical filtration and that the bacterial communities in nodule endophytes vary according to the plant species.