Peter Tellgren wrote:
> I am now struggling with one last issue.
> I am trying to index a difference between 2 fields (possible?)
> I want to be able this way to search by books that has sold x out of y
> available copies.
> 
> something lilke: has books_total - books_sold, :as => books_left
> 
> Is this even possible or should i just make a new column in my table
> containing this value?
> It seems I am in deep water as the index builder is throwing errors at me..
> both columns are integer values though and I can add them seperatly..

It is definitely possible to generate custom attributes.

  has "books_total - books_sold", :as => books_left, :type => :integer

Have a read of the comments for the has() method in
lib/thinking_sphinx/index/builder.rd, it covers some of the syntax you
might find useful.

For searching, try the comments in lib/thinking_sphinx/search.rb

-- James Healy <jimmy-at-deefa-dot-com>  Wed, 15 Apr 2009 23:36:04 +1000

Attachment: signature.asc
Description: Digital signature

Reply via email to