Home > Mobile >  Searching over multiple fields case ignored in Spring Boot
Searching over multiple fields case ignored in Spring Boot

Time:05-03

I couldn't come up with a solution to go over multiple fields and return the ones containing the term searched for (can be one word or more)

@Query("SELECT p FROM Post p WHERE LOWER(p.title) LIKE :searchTitle OR LOWER(p.content) LIKE :searchTitle")
List<Post> searchWithTerm(@Param("searchTitle") String searchTitle);

I wanted to come up with a custom solution but it also didn't help. I want to look at title and content fields of "Post" repository case insensitive.

How can this be done, I am open to methods other than custom SQL queries

CodePudding user response:

postRepository.findAllByTitleContainingIgnoreCaseOrContentContainingIgnoreCaseOrPhotoLinkContainingIgnoreCase(context, context, context, pager);

this was the solution I finally came up with.

  • Related