Add a configuration not to generate alternate phonetic value in analysis-phonetic plugin with DoubleMetaPhone encoder

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

V 2.11.0 Opensearch/anslysis-phonetic plugin
Windows 11
Chrome browser
Docker Desktop

Describe the issue:

When migrating from Solr to Opensearch, there is a token filter which uses “solr.PhoneticFilterFactory”. It uses “DoubleMetaPhone” encoder in the Solr schema. However, when using the “phonetic” type in “analysis-phonetic” plugin with “DoubleMetaPhone” encoder in Opensearch, there is an alternate phonetic value being generated by default. In Solr, there is no alternate phonetic value being generated and it only generates primary phonetic value.
In order to generate the same phonetic values as Solr does, is it possible to add a configuration such as “alternate_phonetic” into “phonetic” of “analysis-phonetic” plugin? If “alternate_phonetic” is set to “false” then no alternate phonetic value being generated. If “alternate_phonetic” is set to “true” then alternate phonetic value being generated. By default, it is set to true if there is no “alternate_phonetic” configuration setting in the Opensearch Mapping.

Here is a suggestion in Opensearch mapping configuration:

"filter": {
  "phoneticdm": {
	"type": "phonetic",
	"encoder": "DoubleMetaPhone",
	"alternate_phonetic": "false",
	"replace": "false"
  }
}

I’ve reviewed the code of “PhoneticTokenFilterFactory” class in “analysis-phonetic” plugin. We can update “PhoneticTokenFilterFactory” class as show below:

.
.
.
private final boolean alternatePhonetic;
.
.
.
public PhoneticTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
        super(indexSettings, name, settings);
.
.
.
       this.alternatePhonetic = settings.getAsBoolean("alternate_phonetic", true);
.
.
.
}

public TokenStream create(TokenStream tokenStream) {
.
.
.
            if (maxcodelength > 0) {
                if (alternatePhonetic) {
                    return new DoubleMetaphoneFilter(tokenStream, maxcodelength, !replace);
                } else {
                    final DoubleMetaphone encoder = new DoubleMetaphone();
                    encoder.setMaxCodeLen(maxcodelength);
                    return new PhoneticFilter(tokenStream, encoder, !replace);
                }
            }
.
.
.
}

After above updates, then “phonetic” of “analysis-phonetic” with “DoubleMetaPhone” encoder can be used either generating alternate phonetic value or no alternate phonetic value being generated by using “alternate_phonetic” configuration setting in Opensearch mapping.

Please find above updated “PhoneticTokenFilterFactory.java” in detail and review to see if it is feasible so that one of the Solr use case of migrating to Opensearch can be achievable?

Relevant Logs or Screenshots: