Mongodb Atlas Search with directive insensitive

I am using MongoDB Atlas Search to perform a search in Collection, for this I created a Atlas Search Index:

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "caption": {
        "type": "string"
      }
    }
  }
}

Here is my aggregation:

[
   {
      "$search":{
         "text":{
            "path":"caption",
            "query":"Ingocnitáá",
            "fuzzy":{
               
            }
         },
         "highlight":{
            "path":"caption"
         }
      }
   }
]

I have below document in my collection:

{caption:"Ct tyu test Ingocnitáá"}

Issue: When I searching Ingocnitaa agreegation returning 0 result.

Is there anything wrong with my Search Index? I want an directive insensitive Search with highlight.

Quesstion on Stack: Mongodb Atlas Search with directive insensitive - Stack Overflow

Hi Kishor,

I tested this in my lab using the same document, index and query as you - I am getting the results just fine when searching for Ingocnitaa :

MongoDB Enterprise > db.search_test_555.find()
{ "_id" : 1, "caption" : "Ct tyu test Ingocnitáá" }
MongoDB Enterprise > db.search_test_555.aggregate([
...    {
...       "$search":{
...          "text":{
...             "path":"caption",
...             "query":"Ingocnitaa",
...             "fuzzy":{
...
...             }
...          },
...          "highlight":{
...             "path":"caption"
...          }
...       }
...    }
... ])
{ "_id" : 1, "caption" : "Ct tyu test Ingocnitáá" }

My index name was "default" which is why I didn’t need to specify it in my query. Is your index name something other than "default"? If so, you will need to specify it in the $search query.

2 Likes

@Harshad_Dhavale Thanks for the reply. I am using M2 (General)
cluster, DO I need a higher plan?

Same query not woking at my end, c heck below screenshot…

Hi @codetycon - Thanks for sharing the details. M2 tiers have a limit of 5 Atlas Search indexes as documented here; so, as long as you don’t have more than 5 Atlas Search indexes, you should be fine on the M2 instance.

The screenshot shows that no index name is specified in the query. Is your index named “default”? If it’s not named “default”, please could you specify the name of the index in the query and try again? I have confirmed that the query returns results successfully in my Atlas UI as well as mongo shell, provided the index name is correctly specified.

2 Likes

I am using default index, you can see in Screnshot it is not working…

ALso check this video: https://drive.google.com/file/d/10yrettA7cuMqWMndAKEq0hGsZGNqZP74/view

Hi @codetycon - thanks for sharing the video clip. One slight difference I noticed in the video and in the original query that you had shared is that the query in the video is missing the “fuzzy”:{} option. When I tested the query on my side, without the fuzzy option, I don’t get the results either. But with the fuzzy option, I get the results. Can you check if adding the fuzzy option changes the query’s behavior?

1 Like

It is working when I used

fuzzy:{ }

Strange when I raised query I was using fuzzy :thinking:. Anyway the issue is resolved, thanks a lot. :pray:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.