3

Is it possible to perform a simple "OR" search in thinking-sphinx? here is a small example in pseudocode.

define_index do
  ...
  has :attr_a, :attr_b
end

Object.search @q, :conditions => {...some cond...}, :with => {:attr_a => value_a OR :attr_b => value_b}

Thanks

Silab
  • 31
  • 2

1 Answers1

2

It is possible, though it's a little more complicated than most queries - you'll need to use Sphinx's select query to work through it. The docs cover this situation.

pat
  • 16,116
  • 5
  • 40
  • 46
  • yes i read that part, but it didn't work. i tried something like this: `with_display = "*, (attr_a = value_a AND attr_b = value_b) OR (attr_c = value_c AND attr_d = value_d) AS display" Object.search q, :conditions => {...}, :sphinx_select => with_display, :with => {'display' => 1}` – Silab Jul 02 '11 at 12:51
  • I found this error `ThinkingSphinx::SphinxError: index medium_core: no such filter attribute 'display'`. What is the 'display' attribute in this case? Is it a column in table? – phuwanart Oct 03 '13 at 09:22