Wildcard search using MongoDB Compass

Hello,

I am trying to do a wildcard search using MongoDB compass and doesn’t seem to work.

I am using Atlas to create a full text search index.

{
  "mappings": {
    "fields": {
      "llt_name": {
        "analyzer": "lucene.standard",
        "type": "string"
      }
    }
  }
}

Using Mongo Compass to write wildcard search and doesn’t seem to work.

[{
    $search: {
        search: {
            query: 'lymph*',
            path: 'llt_name',
            wildcard: true
        }
    }
}, {
    $project: {
        llt_code: 1,
        _id: 0,
        score: {
            $meta: "searchScore"
        }
    }
}, {
    $limit: 100
}]

Any ideas?

Got it to work by using wildcard keyword.

[{$search: {
  "wildcard": {
    query: 'lymph*',
    path: 'llt_name',
    allowAnalyzedField:true
    }
}}]

Hi, Supriya! Glad you got it to work! I actually talked about exactly this case on a presentation I just recorded yesterday. Here is when I talk about building out the stages for fuzzy, autocomplete and wildcard: https://youtu.be/rVU9EjVsrBg?t=2408

Hope it helps!

2 Likes