This work introduces two novel approaches for the selection of active lightpaths that perform a spectrum defragmentation process in elastic optical networks (EONs). The algorithms, named DF-Ants and DF-Gen, are based on ant colony optimization and genetic metaheuristics, respectively, and their objective is to minimize the fragmentation of the entire network, evaluated with two different fragmentation metrics. In this way, the blocking probability is expected to be minimized with the fewest number of reconfigured possible connections. Furthermore, a new performance metric for spectrum defragmentation is also presented, named weighted blocking rate (WBR). Unicast traffic simulations were conducted, showing the feasibility of the proposal.