1

I have these two documents:

{
    "jobTitle": "Asset Manager",
    "description": "Working with assets and so on"
},
{
    "jobTitle": "Coffeshop Manager",
    "description": "Serving assets to clients"
},

I want to find all documents in my database which match "Asset Manager" in "jobTitle" or "description". If possible with some fuzzy.

Currently I use Atlas Search with the $text operator:

{
  index: "meta",
  compound: {
    must: [
      {
        text: {
          query: "Asset Manager",
          path: [
            "meta.jobTitle",
          ],
        },
      },
    ],
  },
}

This returns all the documents mentioned above tho, since Atlas Search splits the query e.g. by space. So it searches for "asset" or "manager". Which is of course not what I want.

I found out that I could use e.g. the $phrase operator which is limited in terms of fuzzy, so also not perfect.

What is the best way to solve this issue?

F.Tepel
  • 140
  • 1
  • 6
  • So just for the record: We decided to keep using the phrases operator and start to build up a synonym database. which we will then use. – F.Tepel Mar 07 '23 at 08:40

1 Answers1

0

Did you try phrase with slop set to 1 or 2? https://www.mongodb.com/docs/atlas/atlas-search/phrase/

Or, I'm not sure which index analyzer you are using, but you could use [keyword][1]?

Here's a tutorial that mentions some of these methods: https://www.mongodb.com/developer/products/atlas/atlas-search-exact-match/

  • Thanks mate. "slop" is not exactly what I was looking for since it does not allow for fuzzy. I also tried to use the lucene.keyword search analyzer but could not get that to work either. The tutorial you suggested I read as well but did not find my exact use case. – F.Tepel Mar 06 '23 at 14:49
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 18 '23 at 15:33