It isn't illegal, but it spoils the user. The owners of the search engins have the right to penalize those who make use of techniques to artificially get a high ranking, you do it at your own risk. If you disagree, you have the right not to get indexed, just set a robot file.