在我的RavenDB中,我在表单上有对象:
{
"Texts1": [
"one two",
"three four"
],
"Texts2": [
"five six",
"seven eight"
],
"Texts3": [
"nine ten",
"eleven twelve"
]
}
为了能够执行我想要的搜索,我正在尝试创建fan-out index(请忽略这一事实,即这不一定以良好的方式扩展):
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
}
尝试将此索引添加到RavenDB会导致错误:
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()
导致此错误的原因是什么?如何解决?
答案 0 :(得分:0)
使用here中的信息我将地图更改为以下解决问题的地图。
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
}
不幸的是,我不明白为什么会这样。仍然欢迎解释。