I don't think it's possible to do what you want to do. When specifying
certain fields, Thinking Sphinx uses the extended search syntax.
http://sphinxsearch.com/doc.html#extended-syntax
So :conditions => {:available_color => 'green'} gets converted to
"@available_color green"
As far as I can tell, there doesn't seem to be a way to specify a
field being empty. Personally, I'd recommend adding in a foreign key
for the colour, and then you could use :with => {:available_color_id
=> [0, 12]}, where 12 is green - nils/NULLs are treated as 0 by Sphinx.
But since you don't want schema changes, the only way I could think of
making this work is by listing all other colours and saying you
*don't* want them:
Model.search "@available_color -(blue|red|yellow)"
Not really a neat solution, though - although you do have the
available_colors array.. so perhaps worth a shot?
--
Pat
Sphinx does support multiple-value-attributes (MVAs) - for integers
only though (although date-times and probably booleans are treated as
ints anyway). So you should be able to create an attribute something
like the following:
has available_colours(:id), :as => :available_colour_ids
--
Pat