Wildcard and Fuzzy together

I would like to do both wildcard and fuzzy search for a text in one call to Atlas cluster. Is there an example I can follow to do it?

This is something I tried:

{
  index: 'test',
  "compound": {
     "must":[
                {
                  "wildcard": {
                    "query": "blo*",
                    "path": "Text",
                    allowAnalyzedField: true
                  }
                },
                  {
          text: {
            query: "blo",
            path: "Text",
            fuzzy: {'maxEdits':2.0}
          }
        }
                ]
  }
}

Thank you,
Supriya

Hi @Supriya_Bansal I tried this query and wasn’t able to reproduce. Maybe revisit your index definition. Here’s my test query:

  index: 'default',
  "compound": {
     "must":[
                {
                  "wildcard": {
                    "query": "Soho*",
                    "path": "name",
                    allowAnalyzedField: true
                  }
                },
                  {
          text: {
            query: "Clan",
            path: "summary",
            fuzzy: {'maxEdits':2}
          }
        }
      ]
  }
}

Using the sample_airbnb.listingsAndReviews sample dataset in Atlas, I also used this index definition:

  "mappings": {
    "dynamic": false,
    "fields": {
      "name": {
        "analyzer": "lucene.keyword",
        "type": "string"
      },
      "summary": {
        "type": "string"
      }
    }
  }
}

I hope this helps. Let me know! :slight_smile:

Hi @Marcus … in your reply i noticed that field (path) is different in the wildcard and fuzzy.
I have a similar requirement but need to perform the Wildcard and fuzzy logic on the SAME field.
So the value of “path:name” under both wildcard and fuzzy does not return any results for the sample_airbnb. listingsAndReviews.

I tried the autocompleter index where wildcard works perfectly fine but as soon as I add Fuzzy logic into the mix, the SCORE is equal to 1 for all the documents matched, which defeats the whole purpose.

So in Atlas Mongodb is it possible to perform Wildcard match search along with Fuzzy search with appropriate score values ?