'Is there a way to perform query_string search in elasticsearch spring boot repository
We are using springboot elastic search starter to get access to ElasticsearchRepository.
Earlier we would search on any field or perform query_string search in spring boot using search and query builder. This search method has been deprecated and searchSimilar has been introduced.
Any way to perform any field search on elastic search using searchSimilar method from ElasticsearchRepository with pagination ?
spring-bootelasticsearch">
elasticsearchspring-dataspring-data-elasticsearch">
spring-data-elasticsearch
Solution 1:[1]
We can do query_string search query by using @Query annotation.
@Query("{\n" +
"\t\"query_string\": {\n" +
"\t \"query\": \"?0\"\n" +
"\t}\n" +
"}")
Page<Incident> findBySearchOnAllFields(String search, Pageable pageable);
Note external query object is missing as spring boot adds the same and if we add then it becomes double and won't work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
