{"record":{"id":"9ff11450615f7d2b","repo":"OrchardCMS/OrchardCore","slug":"unsupported-range-value-type-type","errorCode":null,"errorMessage":"Unsupported range value type: {type}","messagePattern":"Unsupported range value type: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/RangeFilterProvider.cs","lineNumber":86,"sourceCode":"                    throw new ArgumentException(\"Lower and upper bound range types don't match\");\n                }\n\n                switch (nodeKind)\n                {\n                    case JsonValueKind.Number:\n                        if (gt.AsValue().TryGetValue<long>(out var minInt) &&\n                            lt.AsValue().TryGetValue<long>(out var maxInt))\n                        {\n                            rangeQuery = NumericRangeQuery.NewInt64Range(field, minInt, maxInt, includeLower, includeUpper);\n                        }\n                        else if (gt.AsValue().TryGetValue<double>(out var minFloat) &&\n                            lt.AsValue().TryGetValue<double>(out var maxFloat))\n                        {\n                            rangeQuery = NumericRangeQuery.NewDoubleRange(field, minFloat, maxFloat, includeLower, includeUpper);\n                        }\n                        else\n                        {\n                            throw new ArgumentException($\"Unsupported range value type: {type}\");\n                        }\n\n                        break;\n\n                    case JsonValueKind.String:\n                        var minString = gt?.Value<string>();\n                        var maxString = lt?.Value<string>();\n                        rangeQuery = TermRangeQuery.NewStringRange(field, minString, maxString, includeLower, includeUpper);\n                        break;\n\n                    default: throw new ArgumentException($\"Unsupported range value type: {type}\");\n                }\n\n                if (boost != null)\n                {\n                    rangeQuery.Boost = boost.Value;\n                }\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/RangeFilterProvider.cs#L68-L104","documentation":"RangeFilterProvider.CreateFilteredQuery maps numeric range bounds to a Lucene NumericRangeQuery. It first tries long, then double; if the numeric bounds cannot be parsed as either, it throws ArgumentException($\"Unsupported range value type: {type}\") because the JSON number cannot be converted to a supported Lucene numeric range.","triggerScenarios":"Passing a numeric range where bounds are JSON numbers not representable as long or double — e.g. decimal strings with unit suffixes (\"10kg\"), or a value kind typed as Number but holding content that fails both TryGetValue<long> and TryGetValue<double> conversions (such as extremely large values or numbers supplied via GetRawText quirks).","commonSituations":"Bounds containing currency symbols or units (\"$10\"); locale-formatted numbers with comma decimal separators; a decimal bound exceeding double precision handling; query JSON produced by code writing decimals in a form System.Text.Json won't convert to long/double.","solutions":["Supply plain, unit-free numeric literals for both bounds: {\"gt\": 10, \"lt\": 100} or with decimals {\"gt\": 10.5, \"lt\": 99.9}.","If bounds carry units or currency, strip them and convert to a number before building the filter.","For non-numeric (e.g. date) ranges, quote the bounds as strings so the string range path is used.","Confirm the indexed field is numeric and the bound magnitudes fit in a double."],"exampleFix":"// before\n{\"range\": {\"Weight\": {\"gt\": \"10kg\", \"lt\": \"20kg\"}}}\n// after\n{\"range\": {\"Weight\": {\"gt\": 10, \"lt\": 20}}}","handlingStrategy":"validation","validationCode":"if (gt.ValueKind == JsonValueKind.Number &&\n    !(gt.TryGetInt64(out _) || gt.TryGetDouble(out _)))\n{\n    throw new InvalidOperationException($\"Range bound '{gt}' is not a supported numeric type.\");\n}","typeGuard":"static bool IsSupportedNumericBound(JsonElement v) =>\n    v.ValueKind == JsonValueKind.Number && (v.TryGetInt64(out _) || v.TryGetDouble(out _));","tryCatchPattern":"try\n{\n    var query = provider.CreateFilteredQuery(context);\n}\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Unsupported range value type\"))\n{\n    _logger.LogError(ex, \"Non-numeric range bound for numeric field: {Json}\", filterJson);\n    throw new QueryValidationException(\"Numeric range bounds must parse as long or double.\", ex);\n}","preventionTips":["Strip units/currency symbols from bounds before building the filter.","Use invariant numeric formatting when generating query JSON.","Use string bounds for date ranges so the string range path applies."],"tags":["lucene","query-filter","range-query","unsupported-type"],"backgroundTag":"unsupported-dtype","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}