2 questions about Atlas Search

Hello, seeing how we plan to host our database on MongoDB it seemed a logical step for us to take from it as much as possible and thus we would like to embrace Atlas Search as the main workhorse powering our search heavy systems.

I have tried playing with it for the past few days, and while I find the initial setup very easy to do, I have faced some problems/ questions.

Considering the following document:

{
    "recipient": {
        "name": "Silvia de Silva"
    },
    "address": {
        "placeName": "Some Str",
        "buildingNumber": "20",
        "zipcode": "xxxxx",
        "city": "City",
        "country": "Country",
        "isValidated": false
    },
    "shipment": "CXE-43556546",
    "expirationDate": "2022-09-25T20:19:42.001Z",
},

And the following Atlas Search setup:

Problem number 1:

Searching for this documented by address, entering Some Str, 20 will successfully find it, however as secondary findings it will also list unrelated documents, only because of the matching street number, for example:

Completely Unrelated Str, 20
Unrelated Square, 20
etc.

Could you tell me please what I am doing wrong here, and how could I finetune this?

Problem number 2:

As you can see, there are more fields set up that I would like to search this collection by. However, for some reason I am only able to search the documents by the recipient.name and address. If I were to search by expirationDate, be it an exactly precise value, e.g. 2022-09-25T20:19:42.001Z or just 2022, I get 0 results found. The same happens if I attempt to search by shipment ID, for example “CXE-43556546”.

It puzzles me, because as you can see, the fields are inserted into the index and I was not able to find the solution on my own to this problem online, therefore I would like to kindly ask you if you could tell me what I am doing wrong in this case.

Problem number 3:

Finally, I have noticed that Mongo product managers frequently visit these forums, so I would like to report a translation problem regarding the pricing page on your website.

Since I need to present MongoDB Atlas to several people I opted for your webpage in Italian, and most of it is translated. However, the most important section, that is the plan comparison table, still appears in English, the currency is presented in dollars, feature comparisons and descriptions are written in English. It is a jarring experience having to present your product to my peers in such a half-localized fashion.

Grateful,

Ben

Hey there! Thanks for these great questions! Do you mind sharing the query you were testing out for Problem 1&2? That would certainly help me diagnose / provide ideas.

1 Like

Hello there, thank you so much for your reply!

As requested, here is the query:

[
  {
    $search: {
      index: 'products',
      text: {
        query: 'Via Something',
        path: {
          'wildcard': '*'
        }
      }
    }
  }
]

I would like to expand upon the problem #1 as I have done some more testing in the past few days and I have found another issue with how I query it:

In Italy street names are preceded by street type names to indicate their size and type (boulevard, street, alley, square etc.). It is the same as everywhere else, it is just it goes upfront. Now, with the current search query as it is, if I search for any street, say Via Something and Via Completely Else, both will be found and listed because both contain “Via” in the beginning.

Hey @RENOVATIO, I have a few ideas…

Have you tested running this against a compound query? This may help you be more specific, especially given today the documents are in different fields.

db.street.aggregate([
  {
    $search: {
      "compound": {
        "must": [{
          "text": {
            "query": "via something",
            "path": "placeName"
          }
        }],
        "should": [{
          "text": {
            "query": "20",
            "path": "buildingNumber"
          }
        }]
      }
    }
  }
]) 

For question #2, I was thinking - which Index analyzer are you using? (It’s not included in your screenshot). It may be better to specify your expirationDate as Keyword Analyzer.

Also this blog has some more ideas for how to achieve exact matching.

1 Like