diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java b/booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java index 45895e41c..65f815f54 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java @@ -57,19 +57,19 @@ public interface BookRepository extends JpaRepository, JpaSpec """) List findAllFullBooks(); - @Query(""" +@Query(""" SELECT DISTINCT b FROM BookEntity b LEFT JOIN FETCH b.metadata m LEFT JOIN FETCH m.authors a LEFT JOIN FETCH m.categories - LEFT JOIN FETCH b.shelves - WHERE (b.metadata.title like %:text%) - OR (b.metadata.subtitle like %:text%) - OR (b.metadata.description like %:text%) - OR (b.metadata.seriesName like %:text%) - OR (a.name like %:text%) - """) - List findBooksContainingMetadata(@Param("text") String text); + WHERE LOWER(m.title) LIKE LOWER(CONCAT('%', :text, '%')) + OR LOWER(m.subtitle) LIKE LOWER(CONCAT('%', :text, '%')) + OR LOWER(m.description) LIKE LOWER(CONCAT('%', :text, '%')) + OR LOWER(m.seriesName) LIKE LOWER(CONCAT('%', :text, '%')) + OR LOWER(a.name) LIKE LOWER(CONCAT('%', :text, '%')) + ORDER BY m.title ASC +""") +List findBooksContainingMetadata(@Param("text") String text); }