1

How can I get it insensitive to accents:

List<Criteria> andCriteria = new ArrayList<>();

    if (StringUtils.isNoneBlank(dtoFilter.getNombre())) {
        andCriteria.add(Criteria.where("nombre").regex(dtoFilter.getNombre(), "i"));
    }

For example, if I search for Oscar, that I look for both Óscar and Oscar

Jose
  • 1,779
  • 4
  • 26
  • 50
  • I would look at the answers to this question: https://stackoverflow.com/questions/7707671/mongodb-match-accented-characters-as-underlying-character You might have to use a text search index instead of a regex. – Mark B Mar 06 '19 at 14:38
  • I saw that, but I do not see how to do it with Spring Data MongoDb. Greetings. – Jose Mar 06 '19 at 14:40
  • 1
    With a Spring Data Mongodb `TextCriteria` object, you would call `diacriticSensitive(true)` to set the MongoDB `$diacriticSensitive` flag, as described in the official documentation https://docs.spring.io/spring-data/mongodb/docs/2.1.3.RELEASE/reference/html/ – Mark B Mar 06 '19 at 15:04

0 Answers0