我有一个带有集合的实体,我想索引它,但我很难弄清楚如何解决这个问题.问题是我希望使用Lucene以与动态索引相同的方式搜索它.但这不是一个复杂的对象.一个简单的例子;
{
Id: "object/id",
Items: [
{ Id: "1", Name: "One" },
{ Id: "2", Name: "Two" },
{ Id: "3", Name: "Three" }
]
}
Run Code Online (Sandbox Code Playgroud)
我可以使用Lucene轻松查询内置的乌鸦动态索引索引;
物品,名称:"一个"
这看起来干净又高效,对于我需要做的一些事情来说是完美的,但是我试图在我自己的索引中重现这种行为,并且非常糟糕.我告诉它索引该领域,但它仍然拒绝让我打电话给它;
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);
}
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以将这个集合的特定部分添加到索引中,就像这样;
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);
}
}
Run Code Online (Sandbox Code Playgroud)
但这不是我想要做的,我试图将其设置为使用lucene进行查询,就像动态索引一样.这是不是可以做到这一点?