0

In my RavenDB I have objects on the form:

{
  "Texts1": [
    "one two",
    "three four"
  ],
  "Texts2": [
    "five six",
    "seven eight"
  ],
  "Texts3": [
    "nine ten",
    "eleven twelve"
  ]
}

To be able to perform the searches I want I'm trying to create a fan-out index (please ignore the fact that this does not necessarily scale in a well behaved manner):

from doc in docs
from text1 in doc.Texts1
from text2 in doc.Texts2
from text3 in doc.Texts3

select new
{
    Text1 = text1,
    Text2 = text2,
    Text3 = text3
}

Trying to add this index to RavenDB results in an error:

   vid Raven.Studio.Infrastructure.InvocationExtensions.Catch(Task parent, Func`2 func)
   vid Raven.Studio.Models.IndexDefinitionModel.SaveIndexCommand.Execute(Object parameter)
   vid System.Windows.Controls.Primitives.ButtonBase.ExecuteCommand()
   vid System.Windows.Controls.Primitives.ButtonBase.OnClick()
   vid System.Windows.Controls.Button.OnClick()
   vid System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   vid System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   vid MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)



Client side exception:
Raven.Abstractions.Exceptions.BadRequestException: Compilation Errors:

Line 31, Position 4: Error CS0307 - egenskap: <>h__TransparentIdentifier0 cannot be used with type arguments

Source code:
using Raven.Abstractions;
using Raven.Database.Linq;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System;
using Raven.Database.Linq.PrivateExtensions;
using Lucene.Net.Documents;
using System.Globalization;
using System.Text.RegularExpressions;
using Raven.Database.Indexing;


public class Index_Test2 : Raven.Database.Linq.AbstractViewGenerator
{
    public Index_Test2()
    {
        this.ViewText = @"from doc in docs
from text1 in doc.Texts1
from text2 in doc.Texts2
from text3 in doc.Texts3

select new
{
    Text1 = text1,
    Text2 = text2,
    Text3 = text3
}";
        this.AddMapDefinition(docs => 
            from doc in docs
            from text1 in doc.Texts1
            from text2 in doc.Texts2
            from text3 in doc.Texts3
            select new {
                Text1 = text1,
                Text2 = text2,
                Text3 = text3,
                __document_id = doc.__document_id
            });
        this.AddField("Text1");
        this.AddField("Text2");
        this.AddField("Text3");
        this.AddField("__document_id");
        this.AddQueryParameterForMap("__document_id");
        this.AddQueryParameterForReduce("__document_id");
    }
}



   vid System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
   vid Raven.Client.Silverlight.Connection.HttpJsonRequest.<ReadResponseJsonAsync>d__2.MoveNext()

What causes this error and how do I solve it?

Community
  • 1
  • 1
Linus
  • 3,254
  • 4
  • 22
  • 36

1 Answers1

0

Using information from here I changed the map to the following which solves the problem.

from doc in docs
from text1 in ((IEnumerable<dynamic>)doc.Texts1)
from text2 in ((IEnumerable<dynamic>)doc.Texts2)
from text3 in ((IEnumerable<dynamic>)doc.Texts3)

select new
{
    Text1 = text1,
    Text2 = text2,
    Text3 = text3
}

Unfortunately I don't understand why this works. Explanations are still welcome.

Community
  • 1
  • 1
Linus
  • 3,254
  • 4
  • 22
  • 36