{"record":{"id":"1a4f0aebe5cb4e1d","repo":"OrchardCMS/OrchardCore","slug":"missing-value-in-regexp-query","errorCode":null,"errorMessage":"Missing value in regexp query","messagePattern":"Missing value in regexp query","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/RegexpQueryProvider.cs","lineNumber":29,"sourceCode":"    {\n        if (type != \"regexp\")\n        {\n            return null;\n        }\n\n        var first = query.First();\n\n        switch (first.Value.GetValueKind())\n        {\n            case JsonValueKind.String:\n                return new RegexpQuery(new Term(first.Key, first.Value.ToString()));\n\n            case JsonValueKind.Object:\n                var obj = first.Value.AsObject();\n\n                if (!obj.TryGetPropertyValue(\"value\", out var value))\n                {\n                    throw new ArgumentException(\"Missing value in regexp query\");\n                }\n\n                // TODO: Support flags\n\n                var regexpQuery = new RegexpQuery(new Term(first.Key, value.Value<string>()));\n\n                if (obj.TryGetPropertyValue(\"boost\", out var boost))\n                {\n                    regexpQuery.Boost = boost.Value<float>();\n                }\n\n                return regexpQuery;\n            default: throw new ArgumentException(\"Invalid regexp query\");\n        }\n    }\n}\n","sourceCodeStart":11,"sourceCodeEnd":46,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/RegexpQueryProvider.cs#L11-L46","documentation":"RegexpQueryProvider.CreateQuery builds a Lucene RegexpQuery from a JSON object node. The 'value' property containing the regular expression is mandatory; if the object lacks it, the provider throws ArgumentException. The regexp pattern is what defines the term match, so it cannot be defaulted.","triggerScenarios":"A query node like {\"field\": {\"type\": \"regexp\"}} or {\"field\": {\"type\": \"regexp\", \"boost\": 2}} — type is regexp but the \"value\" property with the pattern is absent.","commonSituations":"Hand-written query JSON omitting the pattern; recipes migrated from other search providers using a different property name (e.g. 'pattern' or 'regex'); typos in the property name.","solutions":["Add the required \"value\" string property with the regular expression, e.g. {\"Title\": {\"type\": \"regexp\", \"value\": \"Orch.*\"}}.","Rename any 'pattern'/'regex' keys to exactly \"value\".","Validate the query JSON shape before submitting it to the Lucene query provider."],"exampleFix":"// before\n{\"Title\": {\"type\": \"regexp\", \"pattern\": \"Orch.*\"}}\n// after\n{\"Title\": {\"type\": \"regexp\", \"value\": \"Orch.*\"}}","handlingStrategy":"validation","validationCode":"if (node is JsonObject o && o.TryGetPropertyValue(\"value\", out var v) && v.GetValueKind() == JsonValueKind.String && !string.IsNullOrEmpty(v.GetValue<string>())) { /* safe to call */ }","typeGuard":"static bool HasRegexpValue(JsonNode node) => node is JsonObject o && o.TryGetPropertyValue(\"value\", out var v) && v.GetValueKind() == JsonValueKind.String;","tryCatchPattern":"try { var q = provider.CreateQuery(node); } catch (ArgumentException ex) when (ex.Message == \"Missing value in regexp query\") { // report 'regexp value required' to the user }","preventionTips":["Always set the \"value\" property with the pattern in regexp query JSON.","Use \"value\" (not \"pattern\"/\"regex\") as the property name.","Validate regexp queries in the query editor before saving."],"tags":["lucene","regexp-query","missing-property"],"backgroundTag":"missing-required-argument","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}