1

With the new Atlas Search feature is there a way to escape accents.

I did this index :

{
 "analyzer": "lucene.standard",
 "searchAnalyzer": "lucene.standard",
 "mappings": {
   "dynamic": false,
   "fields": {
     "_id": {
       "type": "string",
       "analyzer": "lucene.keyword"
     },
     "firstName": {
       "type": "string",
       "analyzer": "lucene.french"
     },
     "lastName": {
       "type": "string",
       "analyzer": "lucene.french"
     },
     "email": {
       "type": "string",
       "analyzer": "lucene.standard"
     }
   }
 }
}

With this data :

db.testJTAFulltextSearch.insert({_id: "testFTS3", firstName: "René", lastName: "Martin", email: "rmartin@gmail.com"})
db.testJTAFulltextSearch.insert({_id: "testFTS4", firstName: "Rene", lastName: "Martin", email: "rmartin@gmail.com"})

And with this search :

db.testJTAFulltextSearch.aggregate([{$searchBeta: {index: "customer", text: {query: "René", path: ["_id", "firstName", "email"]}}}])

I got :

{ "_id" : "testFTS3", "firstName" : "René", "lastName" : "Martin", "email" : "rmartin@gmail.com" }

The accents are not escaped (é is supposed to be handled like a e). I was expecting :

{ "_id" : "testFTS3", "firstName" : "René", "lastName" : "Martin", "email" : "rmartin@gmail.com" }
{ "_id" : "testFTS4", "firstName" : "Rene", "lastName" : "Martin", "email" : "rmartin@gmail.com" }

Is there a way to escape accents (diacritics) with Mongodb Atlas Search ?

I guess that I need an ascii folding analyzer but I did not find it in the list of the analyzers : https://docs.atlas.mongodb.com/reference/atlas-search/analyzers/#analyzers-ref

Usage of collation does not seems to work :

db.testJTAFulltextSearch.aggregate([{$searchBeta: {index: "customer", text: {query: "René", path: ["_id", "firstName",
 "email"]}}}], {collation: {locale: "en", strength: 1}})

Still returns only "René"

Doug
  • 14,387
  • 17
  • 74
  • 104
Julien TASSIN
  • 5,004
  • 1
  • 25
  • 40

1 Answers1

0

Have you tried the fuzzy config? It doesn't seem to be enabled by default, but fuzzy: { maxEdits: 2 } should have you covered.

I had a similar issue recently but found out that was actually my fault for setting the wrong config (prefixLength: 1 instead of the default value 0) there - see the thread. In my case, I'm using the term operator instead of text, but I'm not sure how relevant that is.

arthurdenner
  • 79
  • 1
  • 4
  • Thx for your answer, yes fuzzy works, but I want to be diacritics incentive and have fuzzy enabled (Desire should match Désiré but not Dosiro) – Julien TASSIN Apr 03 '20 at 04:24
  • I see. Unfortunately, I don't think only diacritic is available at the moment or if they have any plans to add it. – arthurdenner Apr 03 '20 at 23:59