gpt4 book ai didi

ruby-on-rails - 找不到价格介于

转载 作者:行者123 更新时间:2023-12-02 01:49:39 32 4
gpt4 key购买 nike

我使用:

rails 4.1.1
ruby 2.1.1
thinking sphinx 3.1.1
mysql2

对象索引.rb:

ThinkingSphinx::Index.define :object, :with => :active_record do
indexes price, :sortable => true
...
has created_at, updated_at
end

在狮身人面像配置中:

 sql_attr_float = price
also try
sql_attr_uint = price
result was the same

当我尝试搜索价格在 X 和 Y 之间的对象时:

Object.search :with=> {:price => 100..900}

我得到了没有中间的所有记录,但它起作用了。

当我尝试时:

Object.search :conditions => {:with=> {:price => 100..800}}
or
Object.search :conditions => {:with=> {:price => 100.0..800.0}} for float

我遇到了一个错误:

ThinkingSphinx::SphinxError: index object_core: unsupported filter type 'intrange' on string column - SELECT * FROM `object_core` WHERE `price` BETWEEN 100 AND 800 AND `sphinx_deleted` = 0 LIMIT 0, 20; SHOW META
or for float
ThinkingSphinx::SphinxError: index object_core: unsupported filter type 'floatrange' on string column - SELECT * FROM `object_core` WHERE `price` BETWEEN 100.0 AND 900.0 AND `sphinx_deleted` = 0 LIMIT 0, 20; SHOW META

如何修复它并使用价格范围搜索?

更新:模式.db当我把它变成整数时,问题是一样的:

  t.float  "price",  null: false

thinging_sphinx 生成这个配置文件,把它放在这里 - http://pastebin.com/USGABqdt

最佳答案

我解决了我的问题!我写在/inidices/realty_index.rb

indices :price

但我应该写

has :price, :type => float

因为价格不是搜索的字段,而是排序的属性。

Fields are the content for your search queries

Attributes are used for sorting, filtering and grouping your search results

而且有效!

关于ruby-on-rails - 找不到价格介于,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23590916/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com