{"record":{"id":"d8cbf2627eccb319","repo":"OrchardCMS/OrchardCore","slug":"unsupported-range-value-type-type-rangequeryprovider","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/RangeQueryProvider.cs","lineNumber":79,"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                    default: throw new ArgumentException($\"Unsupported range value type: {type}\");\n                }\n\n                if (boost != null)\n                {\n                    rangeQuery.Boost = boost.Value;\n                }\n\n                return rangeQuery;","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/RangeQueryProvider.cs#L61-L97","documentation":"Within the numeric branch of RangeQueryProvider.CreateQuery, the provider tries to read both bounds as long and then as double. If the JSON value kind is Number but neither parse succeeds (e.g. decimal values beyond double, or malformed numeric JSON), it throws ArgumentException with the unsupported type name. Only integral and double numeric ranges are supported.","triggerScenarios":"A range node whose nodeKind is JsonValueKind.Number but whose bounds cannot be parsed as long or double, e.g. very high-precision decimals like {\"gt\": 0.123456789012345678901234567890}.","commonSituations":"Arbitrary-precision decimal literals in query JSON; culture-formatted numbers pasted into queries; BigInteger-like values exceeding double range.","solutions":["Round or simplify the bound values so they fit in a .NET double (or long for integral bounds).","If the field is actually textual, express bounds as JSON strings so the TermRangeQuery branch is used.","Pre-parse/normalize numbers in the calling code before invoking CreateQuery."],"exampleFix":"// before\n{\"Price\": {\"type\": \"range\", \"gt\": 10.000000000000000000000000001, \"lt\": 20.000000000000000000000000002}}\n// after\n{\"Price\": {\"type\": \"range\", \"gt\": 10.0, \"lt\": 20.0}}","handlingStrategy":"validation","validationCode":"if (decimal.TryParse(bound.ToString(), out var d) && d is >= (decimal)double.MinValue and <= (decimal)double.MaxValue) { /* safe as numeric bound */ }","typeGuard":"static bool IsParsableNumber(JsonNode n) => n.GetValueKind() == JsonValueKind.Number && (n.AsValue().TryGetValue<long>(out _) || n.AsValue().TryGetValue<double>(out _));","tryCatchPattern":"try { var q = provider.CreateQuery(node); } catch (ArgumentException ex) when (ex.Message.StartsWith(\"Unsupported range value type\")) { // fall back to a string TermRangeQuery }","preventionTips":["Keep numeric range bounds within long or double precision.","Avoid pasting culture-formatted or arbitrary-precision decimals into queries.","Unit-test range queries with the extreme values your fields can hold."],"tags":["lucene","range-query","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}