【发布时间】:2015-12-01 00:39:14
【问题描述】:
我有一个实体,上面有一个集合,我想为它编制索引,但我很难弄清楚如何去做。问题是我希望以与动态索引相同的方式搜索它,使用 Lucene。不过,这不是一个复杂的对象。一个简单的例子;
{
Id: "object/id",
Items: [
{ Id: "1", Name: "One" },
{ Id: "2", Name: "Two" },
{ Id: "3", Name: "Three" }
]
}
而且我可以使用Lucene轻松查询内置的raven动态索引索引;
项目,名称:“一个”
这看起来干净高效,非常适合我需要做的一些事情,但我试图在我自己的索引中重现该行为并且失败得很糟糕。我告诉它索引该字段,但它仍然拒绝让我调用它;
public class Things_ByItemProperties : AbstractIndexCreationTask<Thing>
{
public Things_ByItemProperties()
{
Map = things => from thing in things
select new
{
Id = thing.Id,
Items = thing.Items
};
Index(n => n.Items, FieldIndexing.Analyzed);
}
}
我知道我可以将集合的特定部分添加到索引中,像这样;
public class Things_ByItemProperties : AbstractIndexCreationTask<Thing>
{
public Things_ByItemProperties()
{
Map = things => from thing in things
select new
{
Id = thing.Id,
Items = thing.Items,
Items_Name = this.Select( r => r.Name)
};
Index(n => n.Items, FieldIndexing.Analyzed);
}
}
但这不是我想要做的,我试图将它设置为使用 lucene 查询它,就像动态索引一样。有没有办法做到这一点?
【问题讨论】:
标签: ravendb