Add only spring-data-elasticsearch dependency
--------------------Model---------- public class ArunOrder { @Id private Integer id; private Integer userId; private String description; private Boolean hidden; @Field(type = FieldType.Date) private Long createdDate; @Field(type = FieldType.Date) private Long updatedDate; //getter and setter } ------------------Repository-------------- import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.stereotype.Repository; import java.util.List; @Repository public interface MyOrderElastricSearchRepository extends ElasticsearchRepository<ArunOrder , Integer> { //Search a text in order description any where List<ArunOrder> findByDescriptionContaining(String subject); //Search a text in description for order of particular user only List<ArunOrder> findByDescriptionContainingAndUserId(String subject, Integer userId); //Search a text in description for visible order of particular user only List<ArunOrder> findByDescriptionContainingAndUserIdAndHiddenFalse (String subject, Integer userId); } //Search a text in description for visible messages of particular user only and sort by created date List<ArunOrder> findByDescriptionContainingAndUserIdAndHiddenFalseOrderByCreatedDateDesc (String subject, Integer userId); }