{"record":{"id":"f0c09ab3f417420c","repo":"redis/redis-rb","slug":"invalid-phonetic-matcher-supported-matchers-are","errorCode":null,"errorMessage":"Invalid phonetic matcher. Supported matchers are: #{valid_matchers.join(', ')}","messagePattern":"Invalid phonetic matcher\\. Supported matchers are: #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/modules/search/field.rb","lineNumber":100,"sourceCode":"        end\n      end\n\n      # A +TEXT+ field, indexing full-text searchable content.\n      class TextField < Field\n        # Build a +TEXT+ field.\n        #\n        # @param [String, Symbol] name the document attribute the field indexes\n        # @param [Query, nil] query a query the field is bound to, enabling {#match}\n        # @option options [Numeric] :weight the field's scoring weight (+WEIGHT+)\n        # @option options [String] :phonetic phonetic matcher, one of +dm:en+, +dm:fr+, +dm:pt+, +dm:es+ (+PHONETIC+)\n        # @option options [Boolean] :no_stem disable stemming (+NOSTEM+)\n        # @raise [ArgumentError] if +:phonetic+ is not a supported matcher\n        def initialize(name, query = nil, **options)\n          super(name, :text, query, **options)\n          if options[:phonetic]\n            valid_matchers = ['dm:en', 'dm:fr', 'dm:pt', 'dm:es']\n            unless valid_matchers.include?(options[:phonetic])\n              raise ArgumentError, \"Invalid phonetic matcher. Supported matchers are: #{valid_matchers.join(', ')}\"\n            end\n          end\n        end\n\n        # Render this field as the array of +FT.CREATE+ +SCHEMA+ tokens.\n        #\n        # @return [Array] the schema tokens for this field\n        def to_args\n          args = [@name]\n          args << \"AS\" << @alias_name if @alias_name\n          args << @type.to_s.upcase\n          args << \"NOSTEM\" if @options[:no_stem]\n          args << \"WEIGHT\" << @options[:weight].to_s if @options[:weight]\n          args << \"PHONETIC\" << @options[:phonetic] if @options[:phonetic]\n\n          # Add suffix options in specific order: no_index, index_missing, index_empty, sortable, withsuffixtrie\n          args << \"NOINDEX\" if @options[:no_index]\n          args << \"INDEXMISSING\" if @options[:index_missing]","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/modules/search/field.rb#L82-L118","documentation":"The phonetic option on a TEXT field enables Double Metaphone matching, so searches also match similar-sounding words. Redis supports exactly four matchers: dm:en, dm:fr, dm:pt, dm:es. TextField validates the value at construction time (lib/redis/commands/modules/search/field.rb:100); the comparison is exact and case-sensitive, so DM:EN is rejected along with unknown codes.","triggerScenarios":"TextField.new(\"name\", phonetic: \"dm:de\") (German is not shipped); phonetic: \"en\" without the dm: prefix; phonetic: \"DM:EN\" after an upcasing config layer.","commonSituations":"Assuming every Double Metaphone language code exists (dm:de is the usual guess); schema option values passed through case-normalizing config code; typos in schema definitions copied from docs.","solutions":["Use one of the exact lowercase strings dm:en, dm:fr, dm:pt, dm:es","Drop the phonetic option entirely if the language you need is not in the list","Keep matcher strings out of case-normalizing config layers"],"exampleFix":"// before\nTextField.new(\"name\", phonetic: \"dm:de\")\n// after\nTextField.new(\"name\", phonetic: \"dm:fr\")","handlingStrategy":"validation","validationCode":"PHONETIC_MATCHERS = %w[dm:en dm:fr dm:pt dm:es].freeze\n\nph = schema_config.fetch(\"phonetic\", nil)\nraise ArgumentError, \"unsupported phonetic matcher: #{ph}\" if ph && !PHONETIC_MATCHERS.include?(ph)","typeGuard":"ph.nil? || %w[dm:en dm:fr dm:pt dm:es].include?(ph)","tryCatchPattern":"begin\n  TextField.new(name, phonetic: ph)\nrescue ArgumentError => e\n  raise SchemaConfigError, e.message\nend","preventionTips":["Whitelist phonetic values against the four dm: codes","Do not upcase or normalize matcher strings","Cover the matcher value in schema config tests"],"tags":["redis-search","ft-create","phonetic","text-field","argumenterror"],"backgroundTag":"invalid-enum-value","analyzedSha":"2ba9010b91dab9e0fde1fbae3a9aae003f8bc307","analyzedAt":"2026-08-23T03:54:57.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}