redis/redis-rb · error · ArgumentError
index_type must be IndexType::HASH or IndexType::JSON
Error message
index_type must be IndexType::HASH or IndexType::JSON
What it means
Error "index_type must be IndexType::HASH or IndexType::JSON" thrown in redis/redis-rb.
Source
Thrown at lib/redis/commands/modules/search/index_definition.rb:64
# external mutations can't alter this definition.
@prefixes = Array(prefix).dup
append_index_type(index_type)
append_prefix(@prefixes)
append_filter(filter)
append_language(language_field, language)
append_score(score_field, score)
append_payload(payload_field)
end
private
def append_index_type(index_type)
if index_type == IndexType::HASH
@args += ["ON", "HASH"]
elsif index_type == IndexType::JSON
@args += ["ON", "JSON"]
elsif !index_type.nil?
raise ArgumentError, "index_type must be IndexType::HASH or IndexType::JSON"
end
end
def append_prefix(prefix)
unless prefix.empty?
@args << "PREFIX"
@args << prefix.length
prefix.each { |p| @args << p }
end
end
def append_filter(filter)
if filter
@args << "FILTER"
@args << filter
end
end
View on GitHub (pinned to 2ba9010b91)
Solutions
- Set index_type to IndexType::HASH or IndexType::JSON when building the index definition.
- Do not pass arbitrary strings; use the IndexType constants.
When it happens
Trigger: Thrown at lib/redis/commands/modules/search/index_definition.rb:64 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of redis/redis-rb@2ba9010b91 (2026-08-23).
Data as JSON: /api/errors/432f8ba2803e461b.
Report an issue: GitHub.