0

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 ?

2
  • Found solution in link stackoverflow.com/questions/27374618/… Commented Jun 2, 2021 at 12:01
  • Please close the question if felt redundant. Commented Jun 2, 2021 at 12:01

1 Answer 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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.