Thinking sphinx: query price> 0

Is a model of products with the indices

define_index do
indexes: name
indexes description
has product_shops.price,: as =>: price
has catalog_product_connections.catalog_id,: as =>: catalog_id

Need ability to filter by price.

The controller write this:’’, :with => {:price => params[:

It works.
But how to specify the query type: price > 1000?
I have tried this:’’, :with => [‘price>?’, params[: price_from]])

getting error
searchd error (status: 1): invalid or truncated request

What to do?

Sphinx doesn’t have the concept of greater or less than for filters -
not in a simple sense, anyway. The easiest approach is to have a range
between 1000 and a really big number (given it’s an integer, perhaps
2^32): :with => {:price => 1000…(2**32)}

Give that a shot.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs