This paper proposes a constraint-based particle swarm optimization approach to solve the problem of data clustering. Since the existing particle swarm optimization algorithm designed for searching the cluster centroids is mainly to evaluate via a fitness function. Major drawback of Particle Swarm Optimization for the problem of data clustering is computation inefficiency when the complexity of the clustering problem increases. In this paper, we propose a constraint-based particle swarm optimization approach for solving the clustering problems. This study integrated constraint-based reasoning mechanism to reduce the search space and produce better solutions. The proposed approach is compared with a regular Particle Swarm Optimization using UCI repository data sets. According to the experimental results show that the constraint-based particle swarm optimization have faster and more consistent with the user's preferences than a regular Particle Swarm Optimization.