Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Spring Mongo query not ignoring case

I’ve the following query that is not ignoring case. What could be done to make this be case insensitive?

@Query("{'occasionId':?0,'text':/.*?1.*/}")
Page<FreeMessageCard> findByOccasionIdAndTextIgnoreCase(String occasionId, String text, Pageable pageable);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If you use @Query annotation, spring-data will not generate another query based on the naming convention for method names. If you want it to generate a query for you – don’t use @Query annotation. Besides that, you can make your query work by doing this:

@Query("{'occasionId':?0,'text':/.*?1.*/i}")
Page<FreeMessageCard> findByOccasionIdAndTextIgnoreCase(String occasionId, String text, Pageable pageable);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading