SolrNet/NHibernate- using SolrField on child (HasMany) class?
I've started playing around with th开发者_开发知识库e NHibernate integration on Solr. So far, so great. But I have a question that I can't see covered anywhere in the docs. I understand that I can map a List like so:
[SolrField("blah")]
public List<string> Blah {get;set;}
But what if I want to use a custom class? My NHibernate setup looks something like the following:
public IList<MyCustomClass> CustomList {get;set;}
Ideally I'd like to map a single field inside MyCustomClass, effectively making a list of that field. Is this possible? I could do the following:
public IList<MyCustomClass> CustomList {get;set;}
[SolrField("custom")]
private List<DateTime> CustomFieldGetter {
get {
return CustomList.Select(c => c.DateField).ToList();
}
}
But it seems like a giant kludge. Any thoughts?
Mapping composite/nested objects is not currently implemented in SolrNet. The Solr index is a flat structure (see this and this) so SolrNet encourages denormalized mapping classes. This is of course opposed to relational database design, so it's up to you to denormalize your data before feeding it to Solr. This denormalization strongly depends on the kinds of query you will need. See the SchemaDesign wiki page for reference and hints.
If you really know what you're doing, you can try to write and hook up a custom ISolrFieldParser and ISolrFieldSerializer for your MyCustomClass.
精彩评论