Ravendb Indexes JSON reference issue

Viewed 42

We have recently migrated from Raven DB 3.5.9 to 5.1.2. We have collection Fields having documents like

{
    "$id": "1",
    "FieldName": "FName",
    "Rules": [
        {
            "$id": "2",
            "VariantId": "0ad608a6-d489-4e73-b5de-63803fae7ad5",
            "CoveredPlanTypes": [
                "ABC",
                "DEF"
            ]
            "Formatters": [],
            "Transformations": [
                {
                    "$id": "3",
                    "ConditionExpression": {
                        "$id": "4",
                        "SubType": "ConditionCombination",
                        "Name": "AND",
                        "Type": "ConditionComputation"
                    },
                    "Variants": {
                        "$id": "20"
                    }
                },
                {
                    "$id": "21",
                    "ConditionExpression": {
                        "$id": "22",
                        "SubType": "ConditionCombination",
                        "Name": "AND",
                        "Type": "ConditionComputation"
                    },
                    "Variants": {
                        "$id": "41"
                    }
                }
            ]
        },
        {
            "$id": "557",
            "VariantId": "8299a037-2e38-4480-bad9-cf9137786876",
            "CoveredPlanTypes": [
                "ABC"
            ],
            "Formatters": [],
            "Transformations": [
                {
                    "$ref": "3"
                },
                {
                    "$ref": "21"
                },
                {
                    "$id": "558",
                    "ConditionExpression": {
                        "$id": "559",
                        "SubType": "ConditionCombination",
                        "Name": "AND",
                        "Type": "ConditionComputation"
                    },
                    "Variants": {
                        "$id": "611"
                    }
                }
            ]
        }
    ],
    "CreatedOnInstant": "2020-12-16T21:58:49.2241825Z",
    "@metadata": {
        "@collection": "Fields",
        "Raven-Clr-Type": "Domain.Field.Field, Domain",
    }
}

And we have the following Index class

    public class Field_RuleVariantsByPlanType : AbstractIndexCreationTask<Field, Rule>
    {
        public Field_RuleVariantsByPlanType()
        {
            Map = fields => from field in fields
                            from ruleVariant in field.Rules
                            from planType in ruleVariant.CoveredPlanTypes.DefaultIfEmpty("")
                            select new Rule
                            {
                                Id = field.Id,
                                FieldName = field.FieldName,
                                CoveredPlanType = planType,
                                Formatters = ruleVariant.Formatters,
                                Transformations = ruleVariant.Transformations,
                            };
            StoreAllFields(FieldStorage.Yes);
        }
}

When we try to do var rule = await _session.Query<Rule, Field_RuleVariantsByPlanType>().Where(x => x.Id == "fields/7809").ProjectInto<Rule>().ToListAsync();, we do not get the references of Transformations loaded in 2nd rule resolved and they come up as null i.e. "Transformations": [ { "$ref": "3" }, { "$ref": "21" }, Where as if we inspect var rule = await _session.LoadAsync<Field>("fields/7809"); references in json are resolved and we get the proper 3 transformations in 2nd rule this time. Please help

0 Answers
Related