Hi there everyone, I'm new to this list.
I'm spanish and my english is not very good, so excuse me if i say something
in a wrong way.
I'm using thinking_sphinx and almost everything is working good... but i
have a problem and I'm not able to solve it.
I'm coding an app about auctions, and my problem has to see with auction
dates.
I have a model for the items (item.rb), and another one for the auctions
(auction.rb). This is because an item can have many different dates and
places for differet auctions if nobody buys them the first time.
item.rb is indexed using thinking_sphinx, and people can perform searches
about different parameters of the items (description, features, prices,
etc...)
the model index looks like this:
---------
# item.rb
has_many :auctions
[...]
# Indexing
define_index do
indexes owner.name, :as => :owner, :sortable => :true
indexes family.name, :as => :family, sortable => :true
indexes type
indexes description
indexes auction_status.name, :as => :auction_status, :sortable => :true
has user_id, auction_status_id, family_id, price, updated_at
has auctions.date, :as => :acution_dates
end
--------
Then, i also have a method which performs the search:
-------
# parametrs are all coming from the controller:
#
# 'keywords' is a search string, and it works good.
# auction_date is a number of days (ie: 5 for "auctions on next 5 days")
# update_date is a number too (ie: 10 for "items modified during last 10
days")
def self.do_search(keywords, price, auction_date, update_date, page)
conditions = {}
conditions[:price] = 0..price.to_i if not price.nil? and not price == 0
conditions[:auction_dates] =
Time.now.to_i..auction_date.to_i.days.from_now.to_i if not auction_date.nil?
conditions[:updated_at] = update_date.to_i.days.ago.to_i..Time.now.to_i
if not update_date.nil?
Property.search(keywords,
:with => conditions,
:match_mode => :extended,
:order => 'province ASC, price ASC',
:per_page => 10,
:page => page)
end
----------
A search by keywords work, matching any word of the description, the author
name, etc... the 'update_date' works too. But if i pass an auction date, it
does not work... it simply gives me all the results matching the rest of
kywords and conditions. It seems it's not filtering the auction date.
I've tried the query using :with and also using :conditions. None of them
work.
Any help would be appreciated, thanks in advance.
--
Iván Belmonte
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---