0

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

  • Does this answer your question? [How can I search (case-insensitive) in a column using LIKE wildcard?](https://stackoverflow.com/questions/2876789/how-can-i-search-case-insensitive-in-a-column-using-like-wildcard) – Eugene Apr 30 '22 at 22:23

1 Answers1

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

this was the solution I finally came up with.

  • Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P May 02 '22 at 07:24