Create mongo atlas search Multi Analyzer not work

I’m trying to create a multi analyzer following the example in https://www.mongodb.com/docs/atlas/atlas-search/analyzers/multi/#multi-analyzer, but still don’t see the result expected
This is the Search index I created, when I tried to search using the multi keywordAnalyzer is not working as expected

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "keyColumn.keySubcolumn": {
        "type": "string",
        "analyzer": "lucene.standard",
        "multi": {
          "keywordAnalyzer": {
            "type": "string",
            "analyzer": "lucene.keyword"
          }
        }
      }
    }
  }
}

I want to query the exact value an equal condition, but is not working

"text": {
	"query": "My exact value to find",
	"path": { "value": "keyColumn.keySubcolumn", "multi": "keywordAnalyzer" }
}

But if I create a specific lucene.keyword Search index, and use the same query, the result is the expected.
Any idea why is not working when I use the multi analyzer?

Thank you!

The dotted syntax isn’t supported for a field name. Nested document type along with inner field mappings work. Here’s a search playground demonstrating this

This is mentioned in the static mapping section here: https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/#static-mapping-example

If exact match on strings is what you’re after, it is recommended to use the token field type instead though - this allows you to do equals and in operations.

1 Like

Thank you, I missed this “static mapping section”.

For an exact match, I’m using text operator with keyword analyzer, and for search a part I’m using phrase operator with standard analyzer :

"$search": {
	"index": "default",
	"compound": {
		"must": [
			{
				"phrase": {
					"query": "part of a phrase to be find",
					"path": "keyColumn.keySubcolumn"
				}
				"text": {
					"query": "Complete name to be find",
					"path": { "value": "keyColumn.keySubcolumn", "multi": "keywordAnalyzer" }
				}
			}
		]
	}
}

And this is my search index

{
	"mappings": {
	  "dynamic": false,
	  "fields": {
		"keyColumn": {
		  "type": "document",
		  "fields": {
			"keySubcolumn": {
			  "type": "string",
			  "analyzer": "lucene.standard",
			  "multi": {
				"keywordAnalyzer": {
				  "type": "string",
				  "analyzer": "lucene.keyword"
				}
			  }
			}
		  }
		}
	  }
	}
  }

Should I use “type”: “token” instead for exact queries? or it is ok with text operator with keyword analyzer,

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.