开发者

Solr: How can I implement timed discount availablity 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 t开发者_如何学编程his ( 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. Which method would you advise?

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

Much Thanks


You could probably achieve something close enough by using Solr's dynamic fields to get:

.......
"response":{"numFound":1,"start":0,"docs":[
  {
    "name":"The Book",
    "price":"$9.99",
    "discount_1_price":"$3.00",
    "discount_1_synopsis":"thanksgiving special",
    "discount_1_starts":"11-24-2011",
    "discount_1_ends":"11-25-2011",
    "discount_2_price":"$4.00",
    "discount_2_synopsis":"Canadian thanksgiving special",
    "discount_2_starts":"10-10-2011",
    "discount_2_ends":"10-11-2011",
  },
  ........
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜