What is the "best practice" method to index the following in Solr:

I'm attempting to use solr for a book store site.

Each book will have a price but on occasions this will be discounted. The
discounted price exists for a defined time period but there may be many
discount periods. Each discount will have a brief synopsis, start and end
time.

A subset of the desired output would be as follows:

.......
"response":{"numFound":1,"start":0,"docs":[
  {
    "name":"The Book",
    "price":"$9.99",
    "discounts":[
        {
         "price":"$3.00",
         "synopsis":"thanksgiving special",
         "starts":"11-24-2011",
         "ends":"11-25-2011",
        },
        {
         "price":"$4.00",
         "synopsis":"Canadian thanksgiving special",
         "starts":"10-10-2011",
         "ends":"10-11-2011",
        },
     ]
  },
  .........

A requirement is to be able to search for just discounted publications. I
think I could use date faceting for this ( return publications that are
within a discount window ). When a discount search is performed no
publications that are not currently discounted will be returned.

My question are:

   - Does solr support this type of sub documents

In the above example the discounts are the sub documents. I know solr is not
a relational DB but I would like to store and index the above representation
in a single document if possible.

   - what is the best method to approach the above

I can see in many examples the authors tend to denormalize to solve similar
problems. This suggest that for each discount I am required to duplicate the
book data or form a document
association<http://stackoverflow.com/questions/2689399/solr-associations>.
Which method would you advise?

It would be nice if solr could return a response structured as above.

Much Thanks

Reply via email to