views:

72

answers:

1

Hello, I am using Solr and SolrNet for some simple scenarios in an ASP.NET MVC application. For one to one mappings, where I am mapping a single POCO to a document, everything works very smoothly. However, I'm wondering if it is possible to map more complex scenarios like the following. Essentially I have an Auction class which contains a child AuctionItem

    public class Auction
    {
      public virtual int ID { get; set; }
      public virtual string Name { get; set; }
      public virtual AuctionItem {get;set;} 
      public virtual DateTime StartDate { get; set; }
      public virtual DateTime EndDate { get; set; }
    }


    public class AuctionItem 
    {
      public virtual int ID { get; set; }
      public virtual string ItemName{ get; set; } 
      public virtual string ItemDescription{ get; set; }
      public virtual Double ItemPrice{get;set;} 
    }

Obviously I can map the Auction Item with attributes in my code, but I'm wondering how I can include, say, ItemName/ItemDescription/ItemPrice in my Solr document. Obviously the hope here is not to flatten my object graph. Is there a way to achieve this?

+1  A: 

It's currently an open issue (which means that you have the opportunity to implement it! ;-)

Anyway I recommend flattening your classes, that way it's more explicit that there is only one table. In the words of the Solr wiki:

Solr provides one table. Storing a set database tables in an index generally requires denormalizing some of the tables. Attempts to avoid denormalizing usually fail.

Mauricio Scheffer
Cool, to be honest I don't understand the wiki quote and definitely see cases where a deep object graph could map to a single document. I'll take a look at the SOLR source code and see what I can do!
JP
@JP: sure it can be done and it might be convenient some times. I'm just saying it's more straight and simple to have a single class mapped per Solr index.
Mauricio Scheffer