【问题标题】:Solr: How can I implement timed discount availablity in solrSolr:如何在 solr 中实现定时折扣可用性
【发布时间】:2011-04-02 23:29:03
【问题描述】:

我正在尝试将 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 不是关系数据库,但如果可能,我想将上述表示形式存储(和索引)在单个文档中。

  • 解决上述问题的最佳方法是什么

我可以在许多示例中看​​到作者倾向于通过非规范化来解决类似问题。这表明对于每个折扣,我都需要复制图书数据或形成document association。你会建议哪种方法?

如果 solr 可以返回如上结构的响应,那就太好了。

非常感谢

【问题讨论】:

    标签: solr


    【解决方案1】:

    您可能可以通过使用 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 查询看起来如何?
    猜你喜欢
    • 2017-12-22
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-09
    相关资源
    最近更新 更多