【问题标题】:Sunspot solr, searching for a price rangeSunspot solr,搜索价格范围
【发布时间】:2014-05-02 23:51:30
【问题描述】:

我正在使用 Sunspot gem 搜索产品、商店、款式和价格

我能够搜索并使用我的过滤器来修改搜索。

我在过滤器窗格中有价格范围滑块。如何使用此滑块搜索产品的价格范围?

滑块有一个低/高值的输入

      <div class="collapse_content panel-collapse collapse in" id="price_content">
        <div class="panel-body">
          <div id="slide_wrapper">
            <div id="slider-range"></div>
            <input type="text" id="low_end">
            <input type="text" id="high_end">
          </div>
        </div>
      </div>

坦率地说,也许我只是累了,但我什至不确定从太阳黑子销售的角度从哪里开始。

任何帮助将不胜感激。

【问题讨论】:

    标签: jquery ruby-on-rails solr sunspot


    【解决方案1】:

    您可以使用between,它接受一系列数字:

    Sunspot.search(MyModel) do
      with(:price).between(low_price..high_price)
    end
    

    如果您只想搜索最低或最高价格,则可以分别使用greater_than_or_equal_toless_than_or_equal_to 而不是between,它们都接受一个数字:

    Sunspot.search(MyModel) do
      with(:price).greater_than_or_equal_to(low_price)
    end
    

    请参阅Sunspot Wiki 了解更多选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-07
      相关资源
      最近更新 更多