Search for string with spaces and capital letters using atlas search

I am trying to search strings in a few fields using wildcard and a custom analyzer (mentioned below) and I am not getting any response for the query ‘Checking all*’ and I get no results.

The query:

db.getCollection('ruleinventories').aggregate([
{
$search:{
"index":"searchAll",
"wildcard":{
"query":"*Checking all*",
"path":{
"wildcard":"*"
},
"allowAnalyzedField":true
},
"highlight":{
"path":{
"wildcard":"*"
}
}
}
},
{
$project:{
'ruleType':1,
'applicationId':1,
'applicationName':1,
'name':1,
'eventTriggerName':1,
'description':1
}},
]
)

The index:

{
  "analyzer": "lucene.standard",
  "searchAnalyzer": "keywordregex",
  "mappings": {
    "dynamic": false,
    "fields": {
      "applicationId": {
        "representation": "int64",
        "type": "number"
      },
      "applicationName": {
        "type": "string"
      },
      "collectionName": {
        "type": "string"
      },
      "description": {
        "type": "string"
      },
      "documentGroup": {
        "type": "string"
      },
      "eventTriggerName": {
        "type": "string"
      },
      "name": {
        "type": "string"
      },
      "ruleBuilder": [
        {
          "dynamic": true,
          "type": "document"
        },
        {
          "type": "string"
        }
      ],
      "ruleNumber": {
        "type": "string"
      },
      "ruleType": {
        "type": "string"
      }
    }
  },
  "analyzers": [
    {
      "charFilters": [],
      "name": "keywordregex",
      "tokenFilters": [
        {
          "type": "lowercase"
        }
      ],
      "tokenizer": {
        "type": "keyword"
      }
    }
  ]
}

The result I am expecting:

Perhaps try defining the
"path": "description" ?

Hi @Ruchi_Ninawe @Elle_Shwer

Im sure you may have resolved this by now but just replying encase anyone else had similar question.
I think the analyzer and searchAnalyzer usually need to be the same, your keywordregex analyzer looks fine.

It might be worth to mention - in this particular use case it does appear better option might be to use the ‘phrase’ operator with no slop, against a lucene.standard analyzer

here is an example index definition of the keywordregex approach which should meet your needs,

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "applicationId": {
        "representation": "int64",
        "type": "number"
      },
      "applicationName": {
        "analyzer": "keywordregex",
        "searchAnalyzer": "keywordregex",
        "type": "string"
      },
      "collectionName": {
        "analyzer": "keywordregex",
        "searchAnalyzer": "keywordregex",
        "type": "string"
      },
      "description": {
        "analyzer": "keywordregex",
        "searchAnalyzer": "keywordregex",
        "type": "string"
      },
      "documentGroup": {
        "analyzer": "keywordregex",
        "searchAnalyzer": "keywordregex",
        "type": "string"
      },
      "eventTriggerName": {
        "analyzer": "keywordregex",
        "searchAnalyzer": "keywordregex",
        "type": "string"
      },
      "name": {
        "analyzer": "keywordregex",
        "searchAnalyzer": "keywordregex",
        "type": "string"
      },
      "ruleBuilder": [
        {
          "dynamic": true,
          "type": "document"
        },
        {
          "type": "string"
        }
      ],
      "ruleNumber": {
        "type": "string"
      },
      "ruleType": {
        "type": "string"
      }
    }
  },
  "analyzers": [
    {
      "charFilters": [],
      "name": "keywordregex",
      "tokenFilters": [
        {
          "type": "lowercase"
        }
      ],
      "tokenizer": {
        "type": "keyword"
      }
    }
  ]
}