Solr:如何在Solr中实现定时折扣

Solr:如何在Solr中实现定时折扣,solr,Solr,我正在尝试将solr用于书店网站 每本书都有价格,但有时会打折。折扣价格在定义的时间段内存在,但可能有许多折扣期。每个折扣将有一个简短的大纲,开始和结束时间 所需输出的子集如下所示: ....... "response":{"numFound":1,"start":0,"docs":[ { "name":"The Book", "price":"$9.99", "discounts":[ { "price":"$3.00",

我正在尝试将solr用于书店网站

每本书都有价格,但有时会打折。折扣价格在定义的时间段内存在,但可能有许多折扣期。每个折扣将有一个简短的大纲,开始和结束时间

所需输出的子集如下所示:

.......
"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",
        },
     ] 
  },
  .........
一个要求是能够搜索刚刚打折的出版物。我想我可以使用日期刻面(返回折扣窗口内的出版物)。执行折扣搜索时,不会返回当前未折扣的出版物

我的问题是:

  • solr是否支持这种类型的子文档
在上述示例中,折扣是子文档。我知道solr不是一个关系数据库,但如果可能的话,我想在一个文档中存储(和索引)上述表示

  • 实现上述目标的最佳方法是什么
我可以在许多例子中看到作者倾向于去规范化来解决类似的问题。这表明,对于每个折扣,我都需要复制图书数据或表格a。你建议哪种方法

如果solr能够返回如上结构的响应,那就太好了


非常感谢

通过使用Solr的动态字段,您可能可以获得足够接近的结果:

.......
"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",
  },
  ........

我不确定动态场是否能解决这个问题。假设一本书有100个有效折扣。构造的solr查询看起来如何?