Configure Tokenizers and Analyzers for easy searching

I’m in the process of migrating an Elasticsearch index into Opensearch. I’m having issues with getting my index search to get me results.

In Elasticsearch, my index is configured as such

{
	"settings": {
		"analysis": {
			"analyzer": {
				"account_analyzer": {
					"tokenizer": "account_tokenizer"
				}
			},
			"tokenizer": {
				"account_tokenizer": {
					"token_chars": ["digit"],
					"type": "ngram",
					"min_gram": "3",
					"max_gram": "3"
				}
			}
		}
	},
	"mappings": {
		"properties": {
			"accounts": {
				"properties": {
					"accountNumber": {
						"type": "text",
						"analyzer": "account_analyzer"
					}
				}
			}
		}
	}
}

The index in OpenSearch is configured as such:

{
	"settings": {
		"analysis": {
			"analyzer": {
				"account_analyzer": {
					"type": "custom",
					"tokenizer": "account_tokenizer"
				}
			},
			"tokenizer": {
				"account_tokenizer": {
					"token_chars": ["digit"],
					"type": "ngram",
					"min_gram": "3",
					"max_gram": "3"
				}
			}
		}
	},
	"mappings": {
		"properties": {
			"accounts": {
				"type": "nested",
				"properties": {
					"accountNumber": {
						"type": "text",
						"analyzer": "account_analyzer"
					}
				}
			}
		}
	}
}

When I execute the query in Elasticsearch, I get results back. When I execute the query in OpenSearch, I get 0 hits from OpenSearch.

{
	"query": {
		"bool": {
			"must": [
				{
					"match": {
						"accounts.accountNumber": "12345678"
					}
				},
				{
					"match": {
						"accounts.accountLength": 8
					}
				}
			]
		}
	}
}

The account number I’m looking for in the index is saved as 1234####. Coming from Elasticsearch, the ngram tokenizer is supposed to group the characters in the index record and search based on groups indicated by the min_gram and max_gram configuration options. Does this feature translate into OpenSearch. How would I correctly configure the feature in OpenSearch? What plugins would I need to leverage to get the expected functionality?

For extra context, I’m running the docker container with the following command:

docker run -e discovery.type=single-node -e DISABLE_INSTALL_DEMO_CONFIG=true -e DISABLE_SECURITY_PLUGIN=true opensearchproject/opensearch:1.2.0

We can mark this one as solved. I needed to insert the records with ?refresh before I could search them.