3

I use:

rails 4.1.1
ruby 2.1.1
thinking sphinx 3.1.1
mysql2

object_index.rb:

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

In sphinx config:

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

When I try to search object wich price is between X and Y:

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

I got all records without between, but it work's.

When I try:

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

I got an error:

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

How can I fix it and use search in range for price?

upd: schema.db when I make it integer problem was the same:

  t.float  "price",  null: false

thinging_sphinx generate this config file, put it here - http://pastebin.com/USGABqdt

Robert
  • 10,403
  • 14
  • 67
  • 117

1 Answers1

2

I fix my problem! I wrote in /inidices/realty_index.rb

indices :price

But I should write

has :price, :type => float

Because price is not a field for search, but attribut for sorting.

Fields are the content for your search queries

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

And it works!

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304